Arc Forumnew | comments | leaders | submitlogin
. and : I'm not sure I get it
4 points by sacado 6122 days ago | 2 comments
The . and ! notations are great, however I don't understand why a.b.c is equiv. to (a b c) and not to ((a b) c)

As some of you noted (pg himself if I'm right), this syntax is useful especially in the case of structures access, and it should not be abused in other cases. But, if we do so, l.10!x for example should mean "the field x of the tenth hash element of list l", or in plain s-expr ((l 10) 'x).

Thus I have two questions : - is the a way I missed to express elegantly the latter s-expr with funny symbols like . ! or even : ? - in what cases sould a form like (a b 'c d) be translated in a.b!c.d without being felt as an abuse of cool syntax ?



2 points by treef 6122 days ago | link

i would say when you use a.b!c.d couple of times in your code but dont feel like making a macro or setting it to a variable. Naming things is one of the hardest problems in CS so name like a.b!c.d suits that expression well as it turns out to be that expression.

-----

1 point by stefano 6122 days ago | link

. and ! notation are quite cryptic... I prefer (l 10) to l.10

-----