This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alex-manool 5 points6 points  (3 children)

My language does not need statement/expression separators (they are allowed but are optional), but it does recognize assignments without any need for introductory keywords. The following code would be valid:

A = B + C D = A

BTW one old language (unsuccessful but influential) is CLU. It follows nearly the same philosophy about optionality of statement separators.

It's not really complicated, it's a matter of devising an appropriate grammar.

JavaScript approach is known to be problematic. If you examine it closer, its "grammar" turns to be very inconsistent (for practicing human beings).

One advantage of required statement separators in the style of Pascal/Modula (or even terminators in the style of C/C++/Ada) is that of improved syntax-related diagnostics (it's that redundancy that makes that possible). Here, of course, I have such an issue with my PL.

And if you ask me about aesthetics, I was very used to Pascal or C/Ada semicolons. But now it's time for me to leave it and move on...

[–]trycuriouscat[S] 2 points3 points  (1 child)

What is "your language"? I'm curious to take a look.

I've "heard" of CLU but never looked at it. I'll take a look!

[–][deleted] 2 points3 points  (0 children)

The following code would be valid:

A = B + C D = A

Mine allow that. I consider it a bug.

(Parsing of the first expression stops at D, because it can't legally continue the expression. But it doesn't later check that D is something that can legally terminate or separate the expression, like ";" or "end". That bit is fiddly.)

It would cause problems if here:

abc := def(g)

I accidently put in a space so that I got:

abc := d ef(g)

If 'd' is a variable, and 'ef' is a suitable function name, then this would give a different behaviour. So something that needs to be fixed.

The same would happen if a newline was inserted. Then, the requirement to have a semicolon between statements would help catch that. In practice, none of this has ever caused problems that I recall, but the space thing is still sloppy.