On Dec 7, 2007 12:52 PM, Jochen Theodorou <[EMAIL PROTECTED]> wrote:
>
> John Wilson schrieb:
> [...]
> > Groovy has this as a potential issue because it also supports optional
> > typing.
>
> All that follows is a response to this and specific to Groovy:


Actually I think the issue applies to any language which allows Java
classes to be subclassed, supports untyped (or dynamically typed, if
you prefer) parameters and generates class files.

Consider the Java classes C and D

class C {
   public Object foo(C c) {....

class D extends C {
   public Object foo(Object d) {....

now in my arbitrary dynamic language I do

class E extends C {
    def foo(e) {....

elsewhere in another class written in my arbitrary dynamic language I write

def d = new D()
def e = new E()

d.foo(d)
e.foo(e)

If the dynamic language attempts to implement the Java method
selection mechanism at runtime then d.foo(d) will call the method foo
on C.

If the runtime cannot distinguish between a method with an Object
parameter and one with a dynamically typed parameter then e.foo(e)
will also call the method on C.

This behaviour is not *wrong* but I think it's surprising and it's not
the behaviour I want in Ng.

So, in Ng, e.foo(e) calls the method on E.

Note *none* of the above require the dynamic language to support
optional static typing so I think it's an issue for Jython and JRuby
too.

John Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to