digitalmars.D - Ambiguous comment syntax
- Oliver Hoog (11/11) Aug 08 2009 Since one of D's goals is dropping the bad things from C/C++, I wonder
- Adam D. Ruppe (7/10) Aug 08 2009 Pragmatism includes sticking to established habits in humans. This is on...
- Rainer Deyke (10/14) Aug 08 2009 I don't think D needs two inline comment forms, but /+...+/ is no less
- language_fan (3/6) Aug 10 2009 We could also overload .. to define a vector dot product, and *** for
- Daniel Keep (3/14) Aug 08 2009 It's not ambiguous. Tokens are matched with maximal munch meaning that
- Stewart Gordon (5/7) Aug 09 2009 Actually, it isn't always maximal munch - for example, 2..3 tokenises as...
Since one of D's goals is dropping the bad things from C/C++, I wonder why the ambiguous syntax for multi-line comments is still allowed: --- auto p = new int; *p = 10; auto j = 100/*p; <- error --- There is already the unambiguous /+...+/ syntax, so why not drop the /*...*/ syntax? Compatibility? Convenience? I think D should be more pragmatic. What do you think?
Aug 08 2009
On Sun, Aug 09, 2009 at 02:25:04AM +0200, Oliver Hoog wrote:There is already the unambiguous /+...+/ syntax, so why not drop the /*...*/ syntax? Compatibility? Convenience?Both.I think D should be more pragmatic.Pragmatism includes sticking to established habits in humans. This is one of those habits. -- Adam D. Ruppe http://arsdnet.net
Aug 08 2009
Oliver Hoog wrote:There is already the unambiguous /+...+/ syntax, so why not drop the /*...*/ syntax? Compatibility? Convenience? I think D should be more pragmatic. What do you think?I don't think D needs two inline comment forms, but /+...+/ is no less ambiguous than /*...*/. Don't forget about the unary '+' operator: auto p = 1; auto j = 100/+p; (Also, "multi-line"? I only use /*...*/ for inline comments that end before the end of the line. I use multiple instances of '//' if I want a comment that extends beyond the end of a line.) -- Rainer Deyke - rainerd eldwood.com
Aug 08 2009
Sat, 08 Aug 2009 19:26:48 -0600, Rainer Deyke thusly wrote:I don't think D needs two inline comment forms, but /+...+/ is no less ambiguous than /*...*/. Don't forget about the unary '+' operator:We could also overload .. to define a vector dot product, and *** for cross product.
Aug 10 2009
Oliver Hoog wrote:Since one of D's goals is dropping the bad things from C/C++, I wonder why the ambiguous syntax for multi-line comments is still allowed: --- auto p = new int; *p = 10; auto j = 100/*p; <- error --- There is already the unambiguous /+...+/ syntax, so why not drop the /*...*/ syntax? Compatibility? Convenience? I think D should be more pragmatic. What do you think?It's not ambiguous. Tokens are matched with maximal munch meaning that /* is ALWAYS the opening of a multi-line comment.
Aug 08 2009
Daniel Keep wrote: <snip>It's not ambiguous. Tokens are matched with maximal munch meaning that /* is ALWAYS the opening of a multi-line comment.Actually, it isn't always maximal munch - for example, 2..3 tokenises as 2 .. 3 rather than 2. .3. But you're right about comment syntax. Stewart.
Aug 09 2009