Can I make a // block in snap

that block that looks like //

Are you talking about comments?

Uh...yeah. I've done that many times before. It helps with annotating code when bubble comments are just, you know, useless.

If you're talking about comments in scripts then it's super easy:
untitled script pic (11)

Why not make a comment by right-clicking > add comment?

I, and perhaps a few others, have problems with "bubble" comments because they feel so detached from the code. I want a block that I can put between code segments and type text explaining the code segment(s) that are listed below the block comment.

untitled script pic (12)

Is this what you want?

Yeah. I know how to make it anyways (and I have been using it in multiple projects.

I personally suggest not using block comments, at least in a finished project, because even though they don't run any code in them (well, besides a c-block comment), snap does have to run the block, which can decrease performance, although it is probably just a couple microseconds.

I'm a big fan of in-code (custom) comment blocks, as contrasted with Snap!'s yellow official comment windows:

  • they don 't get lost so easily
  • you don't need to widen the block editor window to accommodate them
  • IMAO they're a little easier to edit
  • they're quite flexible:

I recommend e.g.

… or any variety that works for you.

Personally I stopped using blocks like @ten_6044's C-shape block, as it may accidentally swallow blocks that are being dragged around (if you unintentionally release them while near the enclosed area). But that's a matter of taste, and experiences may vary.

Online help
The one purpose that you do need a yellow Snap! command window for is to attach help text with a custom block, as will pop up when you right-click the block and select "help".

Are comments useful?
I try to make any code as self-documenting as reasonably possible, using:

  • meaningful block and variable names;
  • clear and simple structure;
  • limited composition;
  • short definitions scripts (create separate blocks for complicated tasks), etc.

Even so adding a comment may be useful, e.g.

  • to explain the data structure;
  • to explain major design choices, such as why an alternative was rejected.

I do like the little speech bubble instead of // or # - much Snappier :slight_smile:

Off-topic One of the biggest annoyances I have in text languages is that half use // and half use #. Catches me out left, right, and centre every time I swap what I'm coding in!

comments script pic

so like

{comment((comment):: control)((block λ):: control):: control} ::control hat
run (block) :: control

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.