Re: proxy doesn't care about type hints?

2013-04-15 Thread Herwig Hochleitner
2013/4/15 Jim - FooBar(); jimpil1...@gmail.com

  I was very surprised to find out that it is practically impossible to
 subclass some Class Foo and override only 1 overload of some method bar()
 via proxy...especially, if there are more than 1 methods 'bar' taking args
 like below, where InterfaceY extends InterfaceX. Providing the types does
 nothing - it seems proxy only cares about arity


I don't think proxy can do that, save for dispatching to proxy-super
yourself.
gen-class seems to support for overriding based on type signature,
demonstrated here
http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html
Since this is not documented, I wonder if it's officially supported, though.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: proxy doesn't care about type hints?

2013-04-15 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Montag, 15. April 2013 20:57:30 UTC+2 schrieb Jim foo.bar:

  Hi everyone,

 I was very surprised to find out that it is practically impossible to 
 subclass some Class Foo and override only 1 overload of some method bar() 
 via proxy...especially, if there are more than 1 methods 'bar' taking args 
 like below, where InterfaceY extends InterfaceX. Providing the types does 
 nothing - it seems proxy only cares about arity

 void bar(InterfaceX ix); //*not *supposed to be overriden

 abstract void bar(InterfaceY iy); //but this is indeed supposed to be 
 overriden


Does this work?

(proxy [YourClass BarInterface] []
  (bar [x-or-y]
(if (instance? InterfaceY x-or-y)
  (override x-or-y)
  (proxy-super x-or-y

Their might be cases where this works. And where it doesn't. Eg. when the 
X-bar calls the Y-bar.

Meikel

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: proxy doesn't care about type hints?

2013-04-15 Thread Jim - FooBar();

On 15/04/13 21:37, Meikel Brandmeyer (kotarak) wrote:


Their might be cases where this works. And where it doesn't. Eg. when 
the X-bar calls the Y-bar.


Unfortunately that is exactly what is happening... :(

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.uima/uimaj-core/2.4.0/org/apache/uima/analysis_component/JCasAnnotator_ImplBase.java/

line 46 and 67 to save you potential time...
the non-abstract method which accepts the more general Interface, casts 
its argument and delegates to the more specific signature (which is 
supposed to be overriden) with that cast...


The problem is that this is not an uncommon pattern in Java...It may be 
the first time I'm working with it but I've seen it elsewhere...that is 
whay it sort of surprises we don't have a good story for that...even 
gen-class is getting slightly ugly and complicated...but nothing beats 
'proxy' (If i could use it!)...



Jim

--
--
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
--- 
You received this message because you are subscribed to the Google Groups Clojure group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: proxy doesn't care about type hints?

2013-04-15 Thread Jim - FooBar();

On 15/04/13 21:37, Meikel Brandmeyer (kotarak) wrote:


(proxy [YourClass BarInterface] []
  (bar [x-or-y]
(if (instance? InterfaceY x-or-y)
  (override x-or-y)
  (proxy-super x-or-y


I'm sorry I forgot...what is 'override' above? what fn is this? I cannot 
find docs...



Jim

--
--
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
--- 
You received this message because you are subscribed to the Google Groups Clojure group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: proxy doesn't care about type hints?

2013-04-15 Thread Meikel Brandmeyer (kotarak)


Am Montag, 15. April 2013 23:03:56 UTC+2 schrieb Jim foo.bar:

 On 15/04/13 21:37, Meikel Brandmeyer (kotarak) wrote: 
  
  (proxy [YourClass BarInterface] [] 
(bar [x-or-y] 
  (if (instance? InterfaceY x-or-y) 
(override x-or-y) 
(proxy-super x-or-y 

 I'm sorry I forgot...what is 'override' above? what fn is this? I cannot 
 find docs... 


It is just a placeholder for the override logic since you wrote that in 
case of an InterfaceY you want to override the method. You would provide 
override.

Meikel

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: proxy doesn't care about type hints?

2013-04-15 Thread Jim - FooBar();
aaa ok sorry... proxy-super is a no-no in this case...I think at this 
point my best bet is to write a macro that will expand into a gen-class 
skeleton form...there is no other way I'm afraid...the proxy approach 
would be so elegant if it worked!


Jim


On 15/04/13 22:17, Meikel Brandmeyer (kotarak) wrote:



Am Montag, 15. April 2013 23:03:56 UTC+2 schrieb Jim foo.bar:

On 15/04/13 21:37, Meikel Brandmeyer (kotarak) wrote:

 (proxy [YourClass BarInterface] []
   (bar [x-or-y]
 (if (instance? InterfaceY x-or-y)
   (override x-or-y)
   (proxy-super x-or-y

I'm sorry I forgot...what is 'override' above? what fn is this? I
cannot
find docs...


It is just a placeholder for the override logic since you wrote that 
in case of an InterfaceY you want to override the method. You would 
provide override.


Meikel

--
--
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
---
You received this message because you are subscribed to the Google 
Groups Clojure group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
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
--- 
You received this message because you are subscribed to the Google Groups Clojure group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.