Any chance to call Tango as Extended Standard Library

Lars Ivar Igesund larsivar at igesund.net
Sun Jan 18 12:10:48 PST 2009


Andrei Alexandrescu wrote:

> Lars Ivar Igesund wrote:
>> Jason House wrote:
>> 
>>> Andrei Alexandrescu wrote:
>>> 
>>>> I'd be curious to find out more about a runtime queryable struct
>>>> interface. How would it work? What idioms would it enable?
>>> I don't know what Lars is thinking of, but I think of struct
>>> interfaces as a non-polymorphic / compile-time inheritance.  AKA,
>>> you can have a struct implement it, but you can't cast it to a base
>>> struct/interface.  Outside of defining the struct, I'd expect it to
>>> only be usable in templates and is-expressions
>> 
>> Nope, I want something that works at runtime. Inheritance
>> could/should be non-polymorphic and compile-time, but I want to know
>> at runtime that a void* has implemented a given interface.
> 
> Consider you can avail yourself of a function:
> 
> bool implements(Interface)(void* p);
> 
> What would you do with it?

Assuming that I (after getting a positive result from a call to the above, and that I have an interface with the member foo) can then safely call p.foo, I could do a lot of stuff that I can't do today.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list