Remix.run Logo
kazinator a day ago

If you treat assignment as a function, then you have to reify environments as run-time objects, whereby you basically lose lexical scope.

Lisp originally, as in LISP, had assignment as a function: it was called SET.

To use it, you usually had to quote: (SET 'VAR 42).

It worked without an environment parameter because variables were in a pervasive environment, but the quote was needed to get the variable symbol as a run-time value. (SET VAR 42) would mean evaluate VAR to a symbol, and then pass that symbol to the SET function along with 42, so whatever variable was in VAR would be assigned.

Assignment is inherently non-functional, since it is a side-effect, so it is mostly counterproductive to model it as a function.

A pattern matching or logical language can have implicit bindings as the results of an operation, and so produce variables that way. Then instead of assignment you have shadowing, in that some construct binds a variable again that was already used, so that the most recent value then emerges, shadowing the previous one.

bloaf a day ago | parent [-]

So tcl handles it somewhat more elegantly, I think. It also has a set function, but does not require any special quoting because it uses the $ prefix to denote "get the value of this symbol":

    set a 5
    puts $a  #prints 5
and of course because it is modeled as a function (albeit an impure one) you can pass arguments to it as normal:

    set a b
    set $a 5  #equivalent to set b 5
    puts $b   #prints 5
of course, everything in tcl is a string, so this works too lol

    set a 5
    set $a b
    puts $5  #prints b
middayc a day ago | parent [-]

I’ve personally always thought that REBOL’s use of set-words and similar constructs was a strength. It makes sense conceptually, is visually distinguishable, and maintains a strong sense of internal consistency.

REBOL (and by extension, Rye) was never designed around the idea that everything must be a function. It just turns out that this approach fits naturally within the core principles and rules of the language.

All “active” words happen to be functions, because nothing else is needed. The behavior of different word types (and, more broadly, value types) is determined by the evaluator. In that sense, you could say that Rye does have syntax, expressed through its distinct word types.