View mode: basic / threaded / horizontal-split · Log in · Help
November 15, 2005
Re: typeinfo[] construction
kris wrote:
> Georg Wrede wrote:
>> Kris wrote:
>>> D apparently cannot populate non-static arrays of any
>>> type, let alone variable type. Seems I was hoping for too much :-(
>> I'm not sure, but I'd be thoroughly amazed if that was possible, even 
>> in theory.
>> Non-static in itself implies runtime, right?
> Yes and no. Theoretically, the space required can be allocated upon the 
> stack. Optionally the TypeInfo[] noted can be constructed and populated 
> at compile time also. What's left is the population of the _arptr value 
> array: that would be done at runtime; but inline.

Theoretically, I think this could be done at compile-time by building a 
char string containing the appropriate data and assigning a const void* 
to it.  Thus the three parameters:

char 'a'
char 'b'
int 5

would be encoded to something roughly like this (ignoring big/little 
endian rules and such):


using template code.  But doing this elegantly would likely require a 
set of template operations to build upon, and unless Don's been quite 
busy in the past week I doubt this exists yet.  For the moment, I'd mark 
this up as possibly good fodder for a paper on advanced D template 
programming and live with a simpler solution.

Next ›   Last »
1 2
Top | Discussion index | About this forum | D home