[Python-ideas] Modern language design survey for "assign and compare" statements

Tim Peters tim.peters at gmail.com
Sun May 20 01:21:16 EDT 2018


[Steven D'Aprano <steve at pearwood.info>]
> ...
> Red (2011)
> ...
> ... claims to be nearly identical to Rebol.
>
> Wikipedia describes Rebol (and presumably Red) as not having either
> expressions or statements in usual sense. Based on my reading, it is
> kinda-sorta like Forth except without the stack or the postfix syntax.
> The creator of Red describes it:
>
> "About the syntax and semantics, in a nutshell, it's a Lisp without
> parentheses and with infix operator support."
>
> which suggests that assignment could be an expression. There's also a
> "set" function which can assign values, but frankly the Rebol
> programming model confuses me and so I'll count this as a "Possibly, but
> I can't tell for sure so let's say No" for the question of assignment
> expressions.

I was an early REBOL user, and my head still hurts ;-)  It was ...
different, for sure.  The syntax is in some sense extremely simple,
hoping to make it easy to define problem-specific layers of syntax on
top of it.  But I gave up before they got that far.

In any case, everything is "an expression" there, including
assignment.  That's spelled:

    WORD ":"  WHITESPACE+  EXPRESSION

although that's lying a bit.

Here from a Red shell:

>> i: 1
== 1
>> j: k: 2
== 2
>> print [i j k]
1 2 2
>> i: 12 j: 13
== 13
>> print [i j]
12 13
>> x: 12 print add y: 88 x
100
>> y
== 88

That last one shows one of the challenges for people coming from
"normal" languages:  this does the same:

>> (x: 12) (print (add (y: 88) x))
100

showing that it really is a lot like "Lisp without parentheses".
Without the parens, it's impossible to tell where function calls begin
and end without knowing which names denote functions and how many
arguments each function requires!  That's "a feature", they insist ;-)
 To be fair, you really do get used to it quickly for the heavily used
builtin functions.

One more:

>> i1+2=3*88: 6
== 6
>> i1+2=3*88
== 6

Yup!  "i1+2=3*88" is a variable name there :-)

Short course:  definitely "yes" on assignment expressions for Red.
But I'm going to out on a limb and guess that the typical Python
programmer wouldn't find "but Red does it!" persuasive ;-)


More information about the Python-ideas mailing list