1. Multi-line comments

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)
new topic     » topic index » view message » categorize

2. Re: Multi-line comments

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 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Multi-line comments

I think --/ and /-- might work well. They look nice, too. smile

--/ 
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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Multi-line comments

/ 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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Multi-line comments

Hi

I like /-../- looks closer to C /*..*/, yet retains the euphorian way

there could potentially be problems with ..

message[line[i]]

Chris

new topic     » goto parent     » topic index » view message » categorize

6. Re: Multi-line comments

ChrisB said...

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.

new topic     » goto parent     » topic index » view message » categorize

7. Re: Multi-line comments

ChrisB said...

I like /-../-

There is a clash with ...

-- Divide by negative 'c' 
 a = b/-c  
new topic     » goto parent     » topic index » view message » categorize

8. Re: Multi-line comments

bernie said...
ChrisB said...

there could potentially be problems with ..

I rather use derek's ........ because it only
requires typing with lower-case keys because shift keys
are a pain.

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.

new topic     » goto parent     » topic index » view message » categorize

9. Re: Multi-line comments

Hi

Somehow or other, that came out with a single hyphen

/

new topic     » goto parent     » topic index » view message » categorize

10. Re: Multi-line comments

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

new topic     » goto parent     » topic index » view message » categorize

11. Re: Multi-line comments

ChrisB said...

/

commented stuff

/

I wonder if we will every have count or count++ ?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

12. Re: Multi-line comments

groan

Chris

new topic     » goto parent     » topic index » view message » categorize

13. Re: Multi-line comments

jeremy said...

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

new topic     » goto parent     » topic index » view message » categorize

14. Re: Multi-line comments

ChrisB said...

/

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 

new topic     » goto parent     » topic index » view message » categorize

15. Re: Multi-line comments

jeremy said...

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.

new topic     » goto parent     » topic index » view message » categorize

16. Re: Multi-line comments

DerekParnell said...
ChrisB said...

/

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

new topic     » goto parent     » topic index » view message » categorize

17. Re: Multi-line comments

DerekParnell said...

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

new topic     » goto parent     » topic index » view message » categorize

18. Re: Multi-line comments

ghaberek said...

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.

new topic     » goto parent     » topic index » view message » categorize

19. Re: Multi-line comments

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

new topic     » goto parent     » topic index » view message » categorize

20. Re: Multi-line comments

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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu