What Does "Literal" Mean In Rebol's Model?

In programming, the term "literal" generally refers to when a source item expresses a fundamental value and doesn't need to be looked up in a variable. It is essentially inert.

For C:

int value = 10;  // 10 seen here is an "integer literal"
printf("The value is %d", value);  // "string literal" + "integer variable"

But in Rebol's world, the notion of "what's a literal" is context-dependent, and can be very bent up.

is-this-literal?: func ['word [word!]] [
    print ["The word was" word "- you tell me if that was literal!"]
]

>> is-this-literal? foo
The word was foo - you tell me if that was literal!

So what do you think...is FOO a "literal word" or not?

The answer is that we can't particularly answer whether a value is "literal" or not unless we know how it is being used. The term has kind of lost its meaning.

All we can really say in a particular situation is if a value is being used in a "literal way" or not.

In terms of naming, Rebol historically called quoted things "LIT" things.

rebol2>> type? first ['foo]
== lit-word!

But the evaluator gave LIT-WORD!s a behavior...they'd drop their quote mark:

rebol2>> 'foo
== foo

So important to notice: "inertness" wasn't implied by what was being called "literalness"

2 Likes

Coming back to this question, I think the only real meaningful use of literal is to describe when something is taken "as-is".

So what we've called "quoted parameters" are probably better called "literal parameters"

>> foo: func ['arg] [:arg]

>> foo x
== x

Getting away from the term "quoted argument" is didactically beneficial. If anything, META arguments would be "quoted arguments"! :crazy_face:

>> foo: func [^arg] [arg]

>> foo x
== 'x

(Don't take what I just said seriously, ^META parameters should not have been called quoted parameters. (^ void) is null ... and (^ get/any 'asdfasdf) is ~ which is de-isotoped, but not quoted.)

Agreed, quoted also sounds if there is a closing quotation marker, which there isn't.