Polymorphism problem w/local functions?

Magnus Lie Hetland magnus at hetland.org
Wed Jul 20 03:32:50 PDT 2011


On 2011-07-18 18:10:47 +0200, Jonathan M Davis said:

> Well, technically-speaking, that's not really polymorphism, since the choice
> of function is decided at compile time (polymorphism would be dealing with
> overridden functions than overloaded ones),

Right ... thought static overloading was considered a form of 
polymorphism as well. Aanyway... :D

> but I suppose that that's not really here nor there.

Right :)

> In any case, no you can't overload nested functions. You've never been able
> to, and you still can't do it. I don't know _why_ such a restriction exists,
> but it does. Feel free to open up an enhancement request for it. I don't know
> that it'll do much good, but maybe you'll luck out. Not knowing why the
> restriction exists in the first place, I don't know what the chances are of
> that restriction being removed. For all I know, it's an Walter's TODO list.

I see. Not really critical.

As I've been thinking about the problem I was working on, I guess 
dynamic (i.e., "real") polymorphism is what I need anyway; I guess the 
(only?) way to do that would be to have a method on the objects in 
question. (Right...? There are no other dynamic dispatch mechanisms 
that I'm forgetting, other than type-based switch statements?)

Thanks,

- M

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list