. . . continued from Braindump: typing 1
Sometimes, flexibility really is more important than either safety or speed. There are times when you want to be able to construct method calls on-the-fly, and do other funky stuff not possible with static typing and compile-time dispatch. Such abilities can be useful for creating language interpreters, for instance, and for interfacing with external systems.
So, for this purpose, Nexxi provides a compiler-supported Dynamic type that does its own method dispatch. For objects of Dynamic type or in Dynamic containers, the compiler does no compile-time checking, and replaces all method calls with a call to the Dynamic method dispatcher, which does the work at run-time.
At present, there are two potential approaches: a Dynamic base class, from which all other dynamic types must be derived; or a DynamicInterface interface, which all dynamic types must implement. Both would implement a single method: send( name, params... ). My instinct is that the base class is the right way to go, as the compiler is basically ignoring all other methods. But this is still up in the air.
In any event, type-checking for Dynamic types is done at run-time, and method dispatch may fail with run-time errors.
The compiler will supply a basic Dynamic container class that can hold any Object. Any variables defined as type Dynamic will use this container to hold the actual object assigned to the variable. Then, any methods against the variable will be dispatched at run-time using reflection-based dispatching.
| in Design: | |
| on site: |
Markdown: The kinds of formatting markup you'd use in an email will probably work here. For more details on what you can do, check out the Markdown docs.