Multiple line comments in WebAssembly - comments

Is there any way to write a several-lines comment in Wasm (wat)? I know that ;; is used for a one-line comment.

Yes there is, it is (; ;): These comments can also be nested.
(;
my
multi (; line ;)
comment
;)
It is written in the specification Section 6.2.4 (Text Format - Lexical Format - Comments).

Related

format strings and math in here document

This is really two questions combined.
First is: Is there any way to do math inside of a here document?
Second: Is there any way to use format strings in a here document?
An example of this second question is this:
print <<HERE
%s
HERE
% 'string'
yet that doesn't work.
Thankss
Yes to both. By default, heredoc does interpolation with #{}. You can put any Ruby code inside it, and have it evaluated. (To avoid interpolation, you can do <<'HERE'.) For your second part, you have the syntax wrong. You should do:
print <<HERE % 'string'
%s
HERE
In answer to your first question. Yes you can do math in a HERE doc. You would just use the standard #{} expression evaluation.
<<EOF
This is a
multiline doc
with some math in it.
#{3 *18}
EOF
In answer to your second question; you can not do string interpolation in the way you are showing in your example within a HERE doc. Consider the way it is evaluated. It is treated more like a stream that is instantly evaluated when the document is ended.
Typically I would just create your other variables prior to the HERE doc and then use the standard expression evaluation within your HERE doc.
If you want to format your strings directly in the HERE doc it needs to go at the beginning as #sawa pointed out. Notice in the following example how I'm passing multiple strings in an array fashion.
<<EOF % ['string','string2','string3']
%s
%s
%s
HERE

Is it possible to add inline comments in Cobol

Most modern programming languages give a way to add inline comments, generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment, while letting the beginning of the line being an interpreted instruction.
In COBOL, while commenting a whole line is well documented (it can be done by putting an asterisk symbol (*) in column 7), finding documentation on whether or not you can comment the rest of the line beginning at an arbitrary position is harder.
The question is: can you comment the rest of a line beginning at an arbitrary position in COBOL?
Imagining that # is the special character for this kind of comment, here is a fictive example of what is seeked:
*--- This structure is a dummy example
01 MY-STRUCTURE.
05 MY-VARIABLE PIC X VALUE '-'. # Valid values are in {-, a, b}
Pre Cobol 2002 No
In Cobol 2002 *> was introduced. see Cobol 2002 and search in-line comment, which give this example:
05 Field-X Pic XX *> Used in calculating the current THINGY
...
MOVE ABC to XYZ *> Current-XYZ
LMN *> Saved XYZ
There are other some exceptions
In Exec Sql - End-Exec. you are able to use in-line comments (/* */) for some SQL venders (e.g. Oracle). This is not true Cobol though but an embeded language, generally implemented via a pre-compiler. Othere Exec End-exec statement may also allow in-line comments.
There may be other Cobols implementations that allow in line comments
By default many pre Cobol 20002 compiler's only look at columns 7 to 72. So columns 1 to 6 and anything after column 71 can hold comments.
Enterprise COBOL V5.1 will support inline comments
From the Release Highlights
Introduces the floating comment indicator to create a comment anywhere
in the program-text area Enterprise COBOL for z/OS, V5.1 introduces
the floating comment indicator ('*>').
You can specify it anywhere in
the program-text area to indicate that the ensuing text on a line is a
comment line or an inline comment.
A floating comment indicator
indicates a comment line if it is the first character string in the
program-text area (Area A plus Area B, columns 8 - 72), or indicates
an inline comment if it is after one or more character strings in the
program-text area.
No, but you can write a program to "WRAP" your code when you submit it to the compiler. We did this 20 years ago.
for example.
SOME COBOL CODE -- DOUBLE DASH INDICATES COMMENT TO END OF LINE
THEN write a program that looks for the double dashes and have it delete the -- and the text.
Then in your compile jcl, input your source code to the program, and the output to the compiler. Simple. Use the INSPECT statement.
INSPECT LINE, TALLYING CHARACTERS BEFORE INITIAL "--".
MOVE SPACES TO LINE(TALLY:),
And that is it. Removes the comments and sends to compiler.
COBOL documentation. Open, free.
http://opencobol.add1tocobol.com/ OpenCOBOL FAQ and how-to.
http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf (Awesome)
And for a limited time, while it remains Draft and open for comment
http://www.cobolstandard.info/j4/files/std.zip
That last link is almost guaranteed to expire when the COBOL 20xx Draft becomes a ratified ISO Standard, and is not really for redistribution, other than from the ISO PL22 WG4 source.
COBOL supports FIXED and FREE source code formats. FIXED is older, based on 80 column cards, with columns one to six for sequence numbers, 7 for directives and columns 8 thru 72 for program text.
Asterisk in column 7 is a FIXED form COBOL comment line.
OCOBOL* Sequence number field "OCOBOL" in this case, it can be anything
* and comment line indicator
*> inline comment, can be used for FREE format COBOL, as well as FIXED.
There is a trick; place the asterisk in column 7 with the greater than symbol in column 8 and you have a comment line that works in both fixed and free format COBOL.
For compilers that will follow draft 20xx and
>>
directives, there is another trick to assist in FIXED/FREE source compile support.
123456
>>D free format debug line directives
if the D is in column 7, with the two greater thans in 5 and 6, you have mixed FIXED and FREE source text support for debug lines as well.

What do Ruby's printf arguments mean?

Can someone please help me understand the following expression?
printf("%3d - %s\n", counter, name)
That line prints something like this 6 - Install Adobe software
I have looked up information and read the reference but I can't find a simple answer and I'm a bit confused. If you can refer me to a good reference, please do so.
%3d Ok, according to what I could understand, %3d is the number of characters or spaces. Please point me to a reference that explains it.
%s\n I couldn't figure out what this does. I guess \n is a newline or something similar, but by looking at the output it doesn't seem to work like that.
Why are counter and name variables separated by commas?
By looking at the output is seems that %3d is kind of replaced by counter and %s\n is replaced by name. I'm not sure how it works but I would like to understand it.
For syntax look at any printf docs, but check the sprintf docs on ruby-doc.
They're separated by commas because they're separate parameters to the function, but that's more or less syntactic sugar. Think varargs.
Not sure what you mean with the %s\n thing, it's a string then a newline: that's what it outputs.
If your question is specifically "how does the code turn a formatting string and a group of arguments into output" I'd probably search for source, for example, a tiny embedded printf. Nutshell version is that the format string is searched for formatting options, they consume their associated parameters, outputting an appropriately-formatted string. It's a tiny little DSL.

Bash line comment continuation

I have seen some bash/shell comments use the notation
# Some comment block that starts on line 1, but then
#+ continues on line 2 with this silly plus sign.
# And this is another comment line that is not related to the ones above
Does the "#+" help with any kind of parser (like how Doxygen-style comments are used to auto-generate documentation)?
Is this a common practice? I understand that it doesn't hurt anything to include/exclude it, as far as the actual script execution goes, but I'm curious if there are advantages to adopting this style of commenting.
According to the Advanced Bash-Scripting Guide, it looks like this is one of several comment headers one can use to improve clarity and legibility in scripts. This tidbit is presented in the "Assorted Tips" section of the guide:
Use special-purpose comment headers to increase clarity and legibility in scripts.
Here are several of the ones they list in the example block from the guide:
## Caution.
rm -rf *.zzy ## The "-rf" options to "rm" are very dangerous,
##+ especially with wild cards.
#+ Line continuation.
# This is line 1
#+ of a multi-line comment,
#+ and this is the final line.
#* Note.
#o List item.
#> Another point of view.
while [ "$var1" != "end" ] #> while test "$var1" != "end"
Apparently some people find these little bits helpful, but I personally don't see much benefit in doing it.

How do you do block comments in YAML?

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
How do I comment a block of lines in YAML?
YAML supports inline comments, but does not support block comments.
From Wikipedia:
Comments begin with the number sign ( # ), can start anywhere on a line, and continue until the end of the line
A comparison with JSON, also from Wikipedia:
The syntax differences are subtle and seldom arise in practice: JSON allows extended charactersets like UTF-32, YAML requires a space after separators like comma, equals, and colon while JSON does not, and some non-standard implementations of JSON extend the grammar to include Javascript's /* ... */ comments. Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.
# If you want to write
# a block-commented Haiku
# you'll need three pound signs
The specification only describes one way of marking comments:
An explicit comment is marked by a “#” indicator.
That's all. There aren't any block comments.
I am not trying to be smart about it, but if you use Sublime Text for your editor, the steps are:
Select the block
Cmd + / on Mac or Ctrl + / on Linux and Windows
Profit
I'd imagine that other editors have similar functionality too. Which one are you using? I'd be happy to do some digging.
In Vim you can do one of the following:
Comment all lines: :%s/^/#
Comment lines 10 - 15: :10,15s/^/#
Comment line 10 to current line: :10,.s/^/#
Comment line 10 to end: :10,$s/^/#
or using visual block:
Select a multiple-line column after entering visual block via Ctrl+v.
Press r followed by # to comment out the multiple-line block replacing the selection, or Shift+i#Esc to insert comment characters before the selection.
An alternative approach:
If
your YAML structure has well defined fields to be used by your app
AND you may freely add additional fields that won't mess up with your app
then
at any level you may add a new block text field named like "Description" or "Comment" or "Notes" or whatever
Example:
Instead of
# This comment
# is too long
use
Description: >
This comment
is too long
or
Comment: >
This comment is also too long
and newlines survive from parsing!
More advantages:
If the comments become large and complex and have a repeating pattern, you may promote them from plain text blocks to objects
Your app may -in the future- read or update those comments
One way to block commenting in YAML is by using a text editor like Notepad++ to add a # (comment) tag to multiple lines at once.
In Notepad++ you can do that using the "Block Comment" right-click option for selected text.
Emacs has comment-dwim (Do What I Mean) - just select the block and do a:
M-;
It's a toggle - use it to comment AND uncomment blocks.
If you don't have yaml-mode installed you will need to tell Emacs to use the hash character (#).
If you are using Eclipse with the YEdit plugin (an editor for .yaml files), you can comment-out multiple lines by:
selecting lines to be commented, and then
Ctrl + Shift + C
And to uncomment, follow the same steps.
For RubyMine users on Windows:
Open the file in the editor.
Select the block and press:
Ctrl + /,
And you will have the selected block starting with #.
Now if you want to uncomment the commented block, press the same key combination Ctrl + forward slash again.
In the Azure DevOps browser (pipeline YAML editor),
Ctrl + K + C Comment Block
Ctrl + K + U Uncomment Block
There also a 'Toggle Block Comment' option, but this did not work for me.
There are other 'weird' ways too: Right-click to see 'Command Palette' or F1
Then choose a cursor option.
Now it is just a matter of #.
Or even smarter [Ctrl + K] + [Ctrl + C]
In a .gitlab-ci.yml file, the following works:
To comment out a block (multiline): Select the whole block section >
Ctrl K C
To uncomment already commented out block (multiline): Select the
whole block section > Ctrl K U

Resources