Rant after trying Rust a bit
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 6 08:44:43 PDT 2015
On Thursday, 6 August 2015 at 15:11:59 UTC, Russel Winder wrote:
> On Thu, 2015-08-06 at 16:20 +0200, Timon Gehr via Digitalmars-d
> wrote:
>> ← or ⇐ are also fine choices.
>
> And indeed ones taken in Scala, <- can be ←, which looks so
> much nicer to read.
Yes, probably doesn't matter too much which way the arrow points,
you can make up mnemonics for both. I.e. are you transferring a
reference/value to the symbol or is the symbol pointing
at/pinpointing an object/value. I guess the first one is the more
common mnemonic, although for references maybe the latter is more
in line with how you draw diagrams (the arrow pointing to the
instance).
IIRC, in Beta you had this pipeline like assignment/function call
notation
(s,t,v) => func1 => func2 => ((x,y,z), (a,b,c))
Which would be similar to the more conventional
((x,y,z), (a,b,c)) := func2(func1(s,t,v))
With arrows you can allow both directions. The conventional right
to left is easier to read for short expressions. But the
pipelining left to right is easier to read for longer expressions
that go through multiple stages.
I think Rust also allows you to bind elements to a tuple using
both "let" and "mut" in the same tuple expression, so that you
can declare and bind both to variables and constants in a single
expression.
If you have serveral visually distinct array types you probably
could get a coherent and easy to remember syntax for function
calls, value assignment, reference assignment, array assignment,
ranges/dataflow pipelining etc.
More information about the Digitalmars-d
mailing list