REBOL 3.0

Comma as a delimiter in some special cases?

Carl Sassenrath, CTO
REBOL Technologies
6-Feb-2010 20:56 GMT

Article #0306
Main page || Index || Prior Article [0305] || Next Article [0307] || 18 Comments || Send feedback

As you know, REBOL does not use commas. This design decision is critical to the foundation of the language.

In REBOL we write:

[1 2 3]

not:

[1, 2, 3]

Why? Simple, because we want to write:

[1 + 2]

not:

[1, +, 2]

Think about that carefully. In REBOL data can be code, and code can be data. Commas would prevent that concept from working properly. This property makes REBOL quite special and unique in the world of programming languages. So, it's fundamental.

Now, ticket #537 requests a change to the lexical analyzer to give higher strength to commas. Several people have asked for it over the years. What's desired is if someone provides data in the form:

a, b, c

We can easily use the REBOL scanner to parse it without too much trouble.

I spent some time today looking into this request. It's possible, but non-trivial.

While comma doesn't have any special significance in the lexicon, it is used for non-English style decimal points... worldwide. That is, in REBOL:

1.23 = 1,23

People in the USA freak out on that, but if they travel to say, Paris, after the initial shock, they get the idea. I suppose it works the opposite direction as well.

Anyway, comma is not a delimiter in REBOL, it's just a special character used for numbers.

Now that all that's clear, can comma be made a bit stronger to act more like a delimiter? Perhaps. But, we'd need to resolve this ambiguous case:

[abc,123]

Which of these lines would be the correct result?

[abc 123]
[abc 0.123]
**error: comma found in expression

Now, what happens if we write:

[abc,123,456]

Hmmm. You begin to see the problem, and it's non-trivial because comma means two different things here.

So, after some thought, I think we're better off leaving such lines to be processed as strings by parse and keeping the REBOL lexical analyzer as it is.

18 Comments

REBOL 3.0
Updated 22-Mar-2017 - Edit - Copyright REBOL Technologies - REBOL.net