REBOL 3.0

Explicit EvaluationTerminator

Carl Sassenrath, CTO
REBOL Technologies
14-Apr-2007 0:28 GMT

Article #0086
Main page || Index || Prior Article [0085] || Next Article [0087] || 35 Comments || Send feedback

Here's one you will enjoy debating on Saturday night with friends in front of a warm fire while it is still snowing outside...

Should REBOL provide a terminator to argument evaluation?

Please Note

I've been thinking about this for more than 8 years, and I've never reached a positive conclusion. (Lol)

Is this noise? Or, is it useful?

I'm writing it on this blog to see if you can help me conclude one way or the other regarding its validity. (And please excuse my sanity if we've already debated and concluded on this topic. "My brain cache overflowth.")

Imagine you have a function defined as:

afunc: func [a b] [...]

When evaluated, you provide its actual arguments:

afunc 1 "test"

The termination point of the argument evaluation is implied by the function's arity (its number of arguments), not by the syntax of its usage.

So, if you write:

afunc 1

Then REBOL keeps looking for the b argument... even in the case:

afunc 1
if find block value [...]

But, that is actually valid and useful in REBOL. You are allowed to write:

afunc 1 if find block value [...]

So, if you need to enforce evaluation termination, you can do so a few ways:

do [afunc 1 "test"]

which you can also write as:

(afunc 1 "test")

And, don't forget:

apply :afunc [1 "test"]

However, another approach would be to allow an explicit terminator. It might look like this:

afunc 1 .

The . (dot or period) works much like that found in English or other human languages. It tells the interpreter to stop evaluating arguments for the most recent function and proceed with the reduction.

The dot here is not really syntactical like that of the semicolon (;) found in other languages. It is actually part of the expression. It is a semantically-based terminator.

It is possible that we could use the comma instead, just to avoid hard-to-find typos like:

afunc value.

Here the dot is part of the word, not a separate symbol. However, comma has never been allowed in words, so:

afunc value,

would be made the same as:

afunc value ,

The primary ambiguity would become:

afunc 123,

but, I think that is a small problem.

Note that a side-effect of the comma expression termination is that you might also find it of use in data as well as code.

35 Comments

REBOL 3.0
Updated 22-Nov-2024 - Edit - Copyright REBOL Technologies - REBOL.net