shouting versus dotting
Benji Smith
dlanguage at benjismith.net
Wed Oct 8 14:12:15 PDT 2008
Simen Kjaeraas wrote:
> Benji Smith <dlanguage at benjismith.net> wrote:
>
>> This idea first occurred to me when CTFE was introduced. I thought to
>> myself "if we can have compile-time function exectuion", why can't we
>> also have "runtime template instantiation"? Why is it only possible to
>> define a new type (or to choose which type) at compile time?
>>
>> In languages like Ruby, you can attach new methods to an object at
>> runtime. In .NET, you can generate, compile, and load new bytecode
>> instructions on the fly.
>>
>> It's hard to think of cases where you'd really want to construct a new
>> type at runtime. But maybe....automatically generating a library of
>> types by querying a database schema?
>>
>> --benji
>
> The reasons for such things are to be found in the compiler. Optimizing
> an expression whose types you do not know, and allocating space for a
> type that may change its size under your feet - sounds to me like tricky
> business.
Yep. I totally understand why it's not currently possible.
You'd have to have an instance of the compiler always available at
runtime; compiling, loading, and linking on the fly.
Tricky stuff. But it'd be cool.
It wasn't a real suggestion. Just a musing.
--benji
More information about the Digitalmars-d
mailing list