bearophile wrote:
SandeepK:
I too am having difficulty in understanding the benefit of this particular 
proposal.

Read the thread, some of the answers give several use cases.


If I understand it right, the string essentially is still static and hence known 
at compile time?<

It can be unknown at compile-time.

How on earth could that happen? It's always known at compile time.



Anyways, I have wanted similar functionality for a different purpose. In 
graphics is common to do swizzle on vector. A float4 vector has xyzw components 
and some specialized languages like shaders allow you to do shuffle and 
replicate the components.
float4 vec = float4(1.0f,2.0f,3.0f,4.0f);
vec = vec.wzyx;

Note that using dynamic access may be a bit slow for that.

I don't see _anything_ dynamic in this proposal, actually.


On the other hand you can do that in D1 creating a small compile-time function 
that computes the cartesian product to create the strings of the names of those 
function methods (to be used as attributes), that you can add with a mixin (and 
a static foreach, if necessary).
I have shown such code here time ago, don't ask me to write it again :-) This 
is a starting point:

Yes, but the syntax isn't quite as nice as with this proposal.

Reply via email to