Making clojure.lang.IDeref a protocol

2011-08-25 Thread Brent Millare
Hey,

Has there been discussion about making clojure.lang.IDeref a protocol?
I'd like to extend some java types to this the IDeref interface but
currently this is not possible. I feel like this is such a common
idiom, to get values, and doing so will allow me to leverage the @
reader macro for many data types.

Best,
Brent

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Making clojure.lang.IDeref a protocol

2011-08-25 Thread Stuart Halloway
 Hey,
 
 Has there been discussion about making clojure.lang.IDeref a protocol?
 I'd like to extend some java types to this the IDeref interface but
 currently this is not possible. I feel like this is such a common
 idiom, to get values, and doing so will allow me to leverage the @
 reader macro for many data types.
 
 Best,
 Brent

Someday. The challenge is load order. A lot would have to change to make 
protocols available early enough in Clojure's bootstrap to allow this.

That said, I don't know many Java classes that have value-yielding semantics. 
And if you are writing your own class, you can implement the IDeref interface.

Stu


Stuart Halloway
Clojure/core
http://clojure.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Making clojure.lang.IDeref a protocol

2011-08-25 Thread Ken Wesson
On Thu, Aug 25, 2011 at 11:40 AM, Stuart Halloway
stuart.hallo...@gmail.com wrote:
 Has there been discussion about making clojure.lang.IDeref a protocol?

 Someday. The challenge is load order. A lot would have to change to make
 protocols available early enough in Clojure's bootstrap to allow this.

Thinking outside of the box, what about exposing a low level ability
to define a Java interface separately somewhere, then erect the rest
of the machinery of a protocol around it later? Then IDeref can be
just an interface early in bootstrap, but be protocolized late in
bootstrap and available in protocol form thereafter. (This could also
be applicable to potentially-more-useful interfaces like IFn, ISeq,
and Associative, too.)

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Making clojure.lang.IDeref a protocol

2011-08-25 Thread Brent Millare

 That said, I don't know many Java classes that have value-yielding semantics. 
 And if you are writing your own class, you can implement the IDeref interface.

There aren't many value-yielding semantics from many java classes, but
the ones I care about, do matter. Also, in my case, I'm adding value-
yielding semantics to classes that didn't originally have such things.

I'm not writing my own new java class. If I were writing something
that I wanted to extend to an interface, making types with defrecord
and deftype do that nicely for me.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en