--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
Just to clarify, currently Clojure has:
(.p o) ;=> a property access if p is a property
(. o p) ;=> a property access if p is a property
It looks like the proposal will remove that and treat both as method
calls regardless - or am I misunderstanding the proposed change to
Clojure?
I agree that (. o :p) is clearer for property access (and it would be
nice to be portable between CLJ and CLJS) - so I'm in favor of the
change.
Could a warning be added to the (Clojure) compiler to flag (.p o) and
(. o p) if p is a property? - to encourage folks to switch to (. o :p)
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
On Fri, Oct 14, 2011 at 12:28 PM, Fogus <mef...@gmail.com> wrote:Just to clarify, currently Clojure has:
> The ticket http://dev.clojure.org/jira/browse/CLJS-89 and the design
> page http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax
> describe the details of the change in ClojureScript. Can anyone see
> any downsides to this change from a unifying perspective (between
> Clojure and ClojureScript)?
(.p o) ;=> a property access if p is a property
(. o p) ;=> a property access if p is a property
It looks like the proposal will remove that and treat both as method
calls regardless - or am I misunderstanding the proposed change to
Clojure?
Nothing will change about Clojure except that. (. o :p) will be smarter about avoiding reflection. The difference in the other cases in ClojureScript is due entirely to the "function property" problem.
There is no way to avoid a difference in the (.m o) and (. o m) cases. But you're right that clearer docs for those differences will help.
--
2. it adds syntax, which is regrettable. (which is just the flip side of 1)
the difference between field access and function application is
tricky, with clojure's native data (x y) could be either depending on
the value of x or y.
have you thought about adding a special form that only does field
access? get-native-field or something?
seems cleaner and allows for . to be all about method calls in the (future)
> --
> You received this message because you are subscribed to the Google Groups
> "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to
> clojure-dev...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/clojure-dev?hl=en.
>
--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?
+1 on this. I am personally in favour of keeping the current style
since it's not broken.
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
I use CLJS a fair amount, and I realllllly don't like this change. For one, I don't really care about portability here since interop code like this will never make sense in both clj and cljs since it's platform dependent.
> reallllllly don't like this change
Do you mind going into more detail?
Just to be clear. Just because it works doesn't mean it's optimal. Just to be doubly clear:
- No breaking changes happen with Clojure
- if you're using (. o (m)) with or without args in ClojureScript then nothing breaks.
- If you want to be explicit about field access in Clojure or ClojureScript then (. o :p) is the syntax (and in the latter, the only syntax)
> reallllllly don't like this change
Do you mind going into more detail?
--
Now that is the kind of feedback that I was hoping for... and it's pretty darn compelling.
Well whether ClojureScript should do that is another thread. In general we should be careful to hold even the core source up as best if there is potentially a better way.
Well whether ClojureScript should do that is another thread. In general we should be careful to hold even the core source up as best if there is potentially a better way.
> (set! (.woz (.baz (.bar foo))) 1)
Yikes! Where did that come from? I think we can all agree to avoid that.
> (set! (.woz (.baz (.bar foo))) 1)
Yikes! Where did that come from? I think we can all agree to avoid that.
--
--
Why couldn't javascript field access interop be superseded by
keyword-like call, as is e.g. the case for records ?
(. foo :bar) => (:bar foo)
?
2011/10/14 Fogus <mef...@gmail.com>:
For early users, the experience was nearly universal:
1) They expected (.foo x) to 'call' foo, if foo was a 'method' (not really having thought through that there are no true methods in JS, nor any way to disambiguate as there is in Java))
2) They weren't even aware of Clojure's (. x (foo)) syntax, and wouldn't have guessed to try it.
3) Once shown (. x (foo)) they said - "ick! grumble, grumble"
So, it was considered a wart and this proposes to address it. While it may be the case that current ClojureScript users have inured themselves to it, I doubt the initial experience will be much different in the future.
However, if no one cares, we can work on something more important, and try to preclude the stumbles via documentation. The current approach is the best I could come up with, and I'm willing to stick with it.
But bear in mind, fixing it later will become an impossibility. We will only be in this early alpha stage once.
Rich
Everyone: note also - "I'm currently using it in production" is not a valid argument against changes at this time. CLJS, as anything else, simply must go through a period of malleability in order to become great. It has been plainly advertised as being in an early state, and by using it you have implicitly agreed to roll with any changes, in exchange for earlier access. If you can't accept that, then don't use it in production.
For early users, the experience was nearly universal:
1) They expected (.foo x) to 'call' foo, if foo was a 'method' (not really having thought through that there are no true methods in JS, nor any way to disambiguate as there is in Java))
2) They weren't even aware of Clojure's (. x (foo)) syntax, and wouldn't have guessed to try it.
3) Once shown (. x (foo)) they said - "ick! grumble, grumble"
So, it was considered a wart and this proposes to address it. While it may be the case that current ClojureScript users have inured themselves to it, I doubt the initial experience will be much different in the future.
However, if no one cares, we can work on something more important, and try to preclude the stumbles via documentation. The current approach is the best I could come up with, and I'm willing to stick with it.
It is an orthogonal question as to what the behavior of set! should be given any particular form. I'm not sure what dictates we lose anything.
Rich
It is an orthogonal question as to what the behavior of set! should be given any particular form. I'm not sure what dictates we lose anything.
Rich
Rich
Well, they should be considered together, but the lack of quotes leaves me wondering what exactly you were concerned about? Do you have a proposal for set! ?
Rich
Luc P.
--
Luc P.
================
The rabid Muppet
Remember, you are trying to sell this to people who were writing foo.bar - the parens alone are a big hurdle, everything we add beyond that is a tough sell.
This is something users would have to write frequently. I rarely write -anything in Clojure, so I wouldn't call it a convention, nor idiomatic.
Please remember ClojureScript is Clojure hosted on JavaScript. While host targets might be different, that doesn't mean each host should have different syntax for the same things (here, field access). Also note it doesn't mean there is no hope for portable host interop. To the extent you could make like-named shims for some host functionality, you could write portable host-acccessing code.
Finally note the 'point' of having Clojure run on multiple hosts, while not complete portability, is that your skills transfer. If host interop were different everywhere that becomes less true. E.g., you couldn't write portable macros that manipulate interop forms.
Whatever we come up with should work in Clojure too. (. foo :bar) happens to mostly work already. That doesn't mean it should win, but the above considerations apply.
This discussion highlights the fact that you don't design things like this on a mailing list by firing off ideas and +1ing them into consensus. Somewhere the considerations need to be enumerated and any suggestions measured against them.
Fogus's page is a start:
http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax
and there are also some ideas on this topic in my original design notes:
https://raw.github.com/clojure/clojurescript/reader-fixes/devnotes/cljs.org
Rich
My initial reaction was biased toward my own reality (JVM, frequent Java interop).
However this cannot be the only stick yard I should use to favor (-get foo bar)
versus (. foo :bar).
My main unexpressed concerns were the impacts on the actual Java interop in Clojure.
If (. foo bar) still works in Clojure for a while (18 months ?) then
(. foo :bar) has some sex appeal to me and I can live with that.
A meaningful compiler message when the : is missing would also help :)
Two people mentioned (:bar foo) but I expect you have valid reasons not to
pursue in this direction ?
Luc
--
Rich
Thanks for jumping in Rich. This seems to be a point of confusion. I'll go back to the design page and make sure this is super-mega-clear.
Luc P.
On Sat, 15 Oct 2011 20:33:52 -0400