ceylon/ceylon-spec — Issue #206: Should we support dynamic dispatch?
Author: FroMage
Created: 2012-02-22 13:41:56+00:00
State: open
Labels: feature, request for feedback, type system discussion

Bill Burke asked me if we have _dynamic dispatch_. He described it thus:

>That you can write a class that can have attributes, fields and methods dynamically dispatched to a generic method call.
>
> public class MyClass implements DynamicDispatch
>{
> Object invokeMethod(String name, Object[] args, Type[] genericTypes) {...}
>
> void setField(String name, Object arg, Type genericType) {...}
> Object getField(String name, Type genericType) {...}
>}
>
> With dynamic dispatch you could write XML/JSON handlers that allow you to evaluate (and create) json on the fly just like Javascript does. I really hate all the JAXB mess that Java has. Its just way too cumbersome.
>
> I also bet you could do similar things around persistence too.

It sounds to me like this is more than the interception we plan to have (because we're not intercepting calls on an instance), and more than Java's `Proxy` class (which only give you a dynamic implementation of a single interface), while being related to both, and also to our need for the JavaScript backend to have _dynamic types_ for all JS objects that are essentially untyped and dynamic.

That sounds useful, and related to three things we need.

@gavinking mentioned that @RossTate has been thinking about something related to this?