Generic programming ramifications of const by default

Walter Bright newshound1 at digitalmars.com
Sun Jun 10 20:51:25 PDT 2007


Bill Baxter wrote:
> Walter Bright wrote:
>> Bill Baxter wrote:
>>> * "having same type defaults is better for generics"
>>>   (maybe...but I'm not convinced. If you have powerful enough 
>>> metaprogramming it shouldn't be hard to strip const from a type 
>>> tuple, or add it.  And people do far more programming than 
>>> meta-programming.)
>>
>> This is a good point. With const-by-default, you have function type 
>> declarations behaving *fundamentally* different from other 
>> declarations. Given the metaprogramming ability to use tuples to 
>> declare parameters, doing function template type deduction for 
>> parameters, and type inference on parameters, making this 
>> fundamentally different may wind up really screwing things up.
> 
> Yes, it's a good point (it's David Held's point), but again your 
> argument is "may wind up really screwing things up".  On the other hand 
> it may wind up *not* screwing things up.  Gut feelings are great, but 
> neither you nor David have given any concrete examples.

The problem is that metaprogramming is in its infancy. I don't know a 
case that will screw up, but there's not a lot of metaprogramming out 
there. Any sort of glaring inconsistency in how declarations work is a 
potential future train wreck.

It reminds me a bit of how people argued that using < > for template 
arguments would be fine, it was just a minor inconsistency. It wasn't, 
as the inconsistency threw wrench after wrench into the gears of later 
ideas, and eventually forced several wacky syntactical workarounds.



More information about the Digitalmars-d mailing list