Executing pure D at compile-time
kris
foo at bar.com
Thu Feb 8 11:18:22 PST 2007
Andrei Alexandrescu (See Website For Email) wrote:
> kris wrote:
>
>> Following on from the "Regex Redux thread, it seems to me there's an
>> easy way to execute pure D at compile-time. A few elements are needed:
>>
>> 1) the ability to describe a compile-time function call
>> 2) the facility to pass arguments to it, and recieve a return value
>> 3) a means of identifiying the D code to execute
>> 4) a manner in which the pure D is executed
>> 5) a mechanism for ensuring the executed code is docile
>
>
> 6) Ensuring that the code executing at compile-time has full access to
> program's symbols.
>
> 1-5 define a way to define dual functions in D, which is a good thing.
> But without (6), they are useless.
On the contrary, they have access to the arguments passed to them; and
to thoose arguments only.
This should be viewed as a "good thing", since it sandboxes the extent
of behaviour. To do otherwise flies in the face of everything good about
encapsulation.
Taking a step back though, what does it really matter? We're talking
about something that a diminishingly small number of programmers would
actually apply in everyday usage.
Thus, I would hope some serious 'trade off' consideration would be given
to such an approach. After all, there's that assertion that /used/ to be
on the D web site: the one about how D is a "practical language for
practical programmers" or something? Embedding yet another DSL into the
compiler would appear to be a long road for very little practical gain.
- Kris
More information about the Digitalmars-d
mailing list