soegaard / urlang

Urlang is JavaScript with a sane syntax
303 stars 16 forks source link

Dot identifiers in assignment positions. #25

Closed LeifAndersen closed 4 years ago

LeifAndersen commented 4 years ago

While dot identifiers work in reference positions, they don't work in assignment ones:

(define x (object))
(:= x.a 42)

for example throws an error. Obviously I 'could' put the identifier in an import list, but that does seem a bit clunky:

(import x.a)
(define x (object))
(:= x.a 42)

It seems like this syntax does work, but is not documented:

(define x (object))
(:= x "a" 42)
soegaard commented 4 years ago

After his commit the following forms ought to work:

    (:= x.a 42)
    (:= (dot x a) 42)
    (:= x "a" 42)

Multiple dots are allowed as in x.a.b.c or (dot x a b c).