Real World usage of D, Today (was Re: challenge #2: implement the varargs_reduce metafunction)

Bill Baxter dnewsgroup at billbaxter.com
Sat Jan 27 14:16:52 PST 2007


Frits van Bommel wrote:
> Bill Baxter wrote:
>> Andrei Alexandrescu (See Website For Email) wrote:
>>> You will be able to cherry-pick with "is" tests. Walter is opposed to 
>>> manipulating the raw storage attributes.
>>
>> If you have to cherry pick with "is" tests to separate the bits out of 
>> the S above, then why not just use "is" tests to pick the S info off 
>> the type to begin with?
> 
> Because just 'S' is much shorter when you don't want to cherry-pick?

Just wondering if there are that many cases where all want to do is pick 
off S without 'deconstructing' it further.  Especially given Andrei's 
statement "there are lots of things that could go under the vague 
heading of storage class", it seems like it may be rare that you can 
actually just use S as-is without picking out the particular attributes 
you care about -- const or inout or any one of the 'lots of other things'.

And if that's the case then maybe the benefits of having the "template 
foo(S T)(S T x)" syntax are not so huge.  You could get S using
     alias storageof(T) S
in the first line of the template instead.  Or lets say you just want to 
use the constness part of S, which seems like a fairly common thing to 
want.  Then you'll still need something like:
      constof(S) template foo(S T)(S T v) { ... }
But if you have to say constof(S) you might as well just make constof 
operate on T directly instead.
      constof(T) template foo(T)(T v) { ... }

I'm willing to be convinced, but so far it's not clear to me that 
"template xx(S T)" would be all that useful in practice.

--bb



More information about the Digitalmars-d mailing list