NEW-LINE Semantics, and NEW-LINE + INFIX functions

This has a performance advantage as well. In historical Rebol, if you see

x: 10
...whatever...

There's a lookahead step that considers ...whatever..., in case it's:

x: 10
+ 20

If we rule that out, we speed things up.

But It Would Rule Out ELSE/THEN on newlines...

You'd have to write this:

if condition [
   ...
] else [
   ...
]

And you wouldn't be allowed to write this:

if condition [
   ...
]
else [
   ...
]

That's a slight bummer. The new rules regarding BLANK! lines would still disallow:

if condition [
   ...
]

else [
   ...
]

And I'm fine with that being disallowed. But being able to separate an ELSE by a single line break has a nice aspect in that you un-crowd things:

if condition [
   bunch of code here
] else [
   bunch of code here
]

if condition [
   bunch of code here
]
else [
   bunch of code here
]

Not that you would want to use parentheses, but I'll point out this is a case where you couldn't use parentheses to get your newlines because that would block the visibility of the ELSE to infix lookahead:

if condition [
   bunch of code here
] (
    else [
       bunch of code here
   ]
)

Your only option would be the backslash:

if condition [
   bunch of code here
] \
else [
   bunch of code here
]

if condition [
   bunch of code here
]
\ else [
   bunch of code here
]

I don't actually think the first form of that looks so bad. Arguably it helps you realize the next thing is infix (with ELSE you know, but maybe other functions aren't so obvious if you don't know them)

I think the benefits of the "no-newlines in mid expression unless mitigated by lists" rule outweighs the advantages of newlined ELSE/THEN.

1 Like