dynamic classes and duck typing

Walter Bright newshound1 at digitalmars.com
Mon Nov 30 18:04:03 PST 2009


Adam D. Ruppe wrote:
> On Mon, Nov 30, 2009 at 02:02:46PM -0800, Walter Bright wrote:
>> 3. add methods to existing classes (monkey patching) that allow such 
>> extensions
> 
> I think allowing this in general is a bad idea - the opDispatch should
> only be implemented on a small number of classes.
> 
> The reason is simple: a typo in a method name should be a compile time error
> the vast majority of the time.
> 
> If opDispatch was implemented all over the place, allowing random runtime
> extensions, the error is put off until runtime.

Using opDispatch is up to the discretion of the class designer. I doubt 
it would be used in any but a small minority of classes.



More information about the Digitalmars-d mailing list