[CLJS-89] Simplify the dot access special form. Created: 14/Oct/11 Updated: 01/Feb/12 Resolved: 01/Feb/12
Currently ClojureScript provides the following dot access syntaxes:
This is potentially confusing. Especially considering that Clojure looks as follows:
This would be a breaking change, but would shorten the divergence between Clojure and ClojureScript.
|Comment by Fogus [ 16/Nov/11 9:09 AM ]|
The implementation on the prop-lookup branch is functional and has associated tests. Ready for inclusion.
|Comment by Benjamin Conlan [ 02/Dec/11 12:02 AM ]|
I've just given this a quick spin and it works beautifully (at least regarding the property value vs property function syntax).
But after looking at my code I can't help but think that for the non-function case (ie json data) just using the maps symbol operator might be more desirable instead of (.-p o))
so json such as:
could be accessed like:
But in saying this I haven't put any thought into this statement (and of course the suggested code doesn't work anyway in the master/prop-access branches).
In coming full circle, I'm just appreciative of your work on the prop-access branch.
|Comment by Stuart Sierra [ 03/Jan/12 5:05 PM ]|
Back in the dark ages before Clojure 1.0, you always had to write this;
Later, but before the introduction of (.m o) syntax, this was shortened to (. o x) for both methods and fields. What if we went back to the original dot operator syntax, but assume that (.m o) always means a method call:
|Comment by Thomas Scheiblauer [ 01/Feb/12 12:37 PM ]|
I would also prefer Stuart's solution due to the reasons he mentioned and because the currently implemented concatenation of sugar characters (.-somefield obj) didn't really make the matter taste more sweet it feels rather clumsy to me.
|Comment by David Nolen [ 01/Feb/12 4:09 PM ]|
At this point it's probably water under the bridge. If you're interested in memfn, please submit a patch
|Comment by David Nolen [ 01/Feb/12 4:53 PM ]|