1. Multi-line comments
- Posted by DerekParnell (admin) Feb 22, 2009
- 1024 views
This is a request for ideas about what syntax we can implement for multi-line comments.
Just for testing purposes, I've implemented them so far using [[ to start them and ]] to end them.
- What do you think we should use?
- Should they be nestable? (I think not)
- Should we ignore the end-marker if its inside a text literal that has been commented out? (I think not)
2. Re: Multi-line comments
- Posted by jeremy (admin) Feb 22, 2009
- 1047 views
What's wrong with something familure to most people, good old C comments? /* ... */ ? Pascal comments are also easy to read, {* ... *} but C comments are easier to type. and are certainly easy to type but looks too much like valuable code to me (even though it is not).
What ever the syntax would be, I think this should work:
/* The following code is causing problems, comment the whole thing out for testing purposes /* * Tell what this block of code does */ code code code sequence text_literal = /# Hello World */ This is a test # /* * Tell what this block of code does */ code code code */ good code good code
3. Re: Multi-line comments
- Posted by ghaberek (admin) Feb 22, 2009
- 1021 views
I think --/ and /-- might work well. They look nice, too.
--/ This is a mutli- line comment... /-- --/ A single line with multi-line comment tags /-- --/-- I assume tags like this would work also, due to how they would be read by the interpreter... --/--
-Greg
4. Re: Multi-line comments
- Posted by jeremy (admin) Feb 22, 2009
- 1033 views
/ and / has the benefit of easily converting single line comments to multi line comments. Many places you have:
-- Function: greet() -- Parameters: -- * name - Name of person to greet -- * greeting - Message to greet with (defaults to Hello) --
Simply add two lines:
/-- -- Function: greet() -- Parameters: -- * name - Name of person to greet -- * greeting - Message to greet with (defaults to Hello) -- --/
Although, the formatting of that is a bit off. I wonder if -/ and /- would work as well, so formatting can be correct:
/- -- Function: greet() -- Parameters: -- * name - Name of person to greet -- * greeting - Message to greet with (defaults to Hello) -- -/
Jeremy
5. Re: Multi-line comments
- Posted by ChrisB (moderator) Feb 23, 2009
- 1002 views
Hi
I like /-../- looks closer to C /*..*/, yet retains the euphorian way
there could potentially be problems with ..
message[line[i]]
Chris
6. Re: Multi-line comments
- Posted by bernie Feb 23, 2009
- 983 views
Hi
I like /-../- looks closer to C /*..*/, yet retains the euphorian way
there could potentially be problems with ..
message[line[i]]
Chris
I rather use derek's ........ because it only
requires typing with lower-case keys because shift keys
are a pain.
7. Re: Multi-line comments
- Posted by DerekParnell (admin) Feb 23, 2009
- 983 views
I like /-../-
There is a clash with ...
-- Divide by negative 'c' a = b/-c
8. Re: Multi-line comments
- Posted by DerekParnell (admin) Feb 23, 2009
- 1040 views
Chris is right, the double ']]' is already a valid syntax possibility so we can't use that. Also, the '[' and ']' are shifted on some non-USA keyboard layouts.
9. Re: Multi-line comments
- Posted by ChrisB (moderator) Feb 23, 2009
- 998 views
Hi
Somehow or other, that came out with a single hyphen
/
10. Re: Multi-line comments
- Posted by ChrisB (moderator) Feb 23, 2009
- 1003 views
Hi
Somehow or other, that came out with a single hyphen
/
commented stuff
/
I can't think of instances where those character sequences are valid code.
(and they aren't shifted on my UK keyboards)
Chris
11. Re: Multi-line comments
- Posted by jeremy (admin) Feb 23, 2009
- 1021 views
/
commented stuff
/
I wonder if we will every have count or count++ ?
Jeremy
13. Re: Multi-line comments
- Posted by mattlewis (admin) Feb 23, 2009
- 1012 views
- Last edited Feb 24, 2009
I wonder if we will every have count or count++ ?
I doubt we could ever have count. As much as I like those operators in other languages, they just don't seem to me to fit into euphoria.
Matt
14. Re: Multi-line comments
- Posted by DerekParnell (admin) Feb 23, 2009
- 997 views
- Last edited Feb 24, 2009
/
commented stuff
/
I can't think of instances where those character sequences are valid code.
? 4 /-- a line comment 3 ? 2 --/ another line comment
output:
1.333333333 2
15. Re: Multi-line comments
- Posted by DerekParnell (admin) Feb 23, 2009
- 992 views
- Last edited Feb 24, 2009
I wonder if we will every have count or count++ ?
Probably not. There is not much difference between count++ and count+=1 , and a double dash will just mark the start of a line comment.
16. Re: Multi-line comments
- Posted by ghaberek (admin) Feb 23, 2009
- 988 views
- Last edited Feb 24, 2009
/
commented stuff
/
I can't think of instances where those character sequences are valid code.
? 4 /-- a line comment 3 ? 2 --/ another line comment
output:
1.333333333 2
That's why I suggested --/ open /-- close. Since --/ is already a comment, the interpreter just waits until /-- to continue reading code...
-Greg
17. Re: Multi-line comments
- Posted by mattlewis (admin) Feb 23, 2009
- 1047 views
- Last edited Feb 24, 2009
There is not much difference between count++ and count+=1 , and a double dash will just mark the start of a line comment.
The biggest difference is that (at least in other languages that have them) the pre/post-increment/decrement operators return a value, which can be incredibly useful, but IMHO isn't very Euphorian.
Contrived example:
sequence s = get_some_input() integer ix = 0 while ix++ < length( s ) do -- process s[ix] end while
Matt
18. Re: Multi-line comments
- Posted by DerekParnell (admin) Feb 23, 2009
- 1036 views
- Last edited Feb 24, 2009
That's why I suggested --/ open /-- close. Since --/ is already a comment, the interpreter just waits until /-- to continue reading code...
Sorry Greg, I meant to reply to this one earlier too, but I got side-tracked.
The problem with "/" is that this sequence of characters is already in use in a lot files as an informal code for embedded documentation, which can be extracted by tools to create HTML docs or similar. And as I've shown, "/--" is already ambiguous without a context so that will slow down the parsing a bit.
19. Re: Multi-line comments
- Posted by znorq2 Feb 24, 2009
- 983 views
So, why not just use /* */..? Not Euphorian, but it's just comments - and it's something everybody (..) is familiar with....?
It's also very quick to use (numpad)...
Kenneth / ZNorQ
20. Re: Multi-line comments
- Posted by ScriptBasic Mar 01, 2009
- 996 views
I had mention this idea in another thread and is how ScriptBasic does multi-line stings and comments.
A$ = """This is "a" mult-line string""" '"""This is ('a') multi-line comment"""
Anything between the """ and """ is verbatim.