Fully transitive const is not necessary

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 2 13:40:23 PDT 2008


"Bill Baxter" wrote
> Steven Schveighoffer wrote:
>> "Janice Caron" wrote in message
>
>> The point is that logical const is still possible, even with transitive 
>> const, because the global namespace is not const.  There is no way around 
>> this except with pure functions.  Which I think you agree.
>>
>> HOWEVER, the point that everyone is arguing is why does logical const 
>> make pure functions or functional programming impossible?  Clearly, it is 
>> ALREADY POSSIBLE to have logical const, and clearly, pure functions are 
>> possible! I'm saying transitive const is mathematically equivalent to 
>> logical const ALREADY.  Please try and grasp that concept.
>
> Globals are a loophole.  Pure will close that loophole.  Allowing mutable 
> members would be another loophole.  Maybe pure can just close that one 
> too?  It would have to check that any access to a const object does not 
> touch mutable fields.  It seems possible.  Would it be impossible for the 
> compiler to check that for some reason?  Probably pure functions will only 
> be able to call other pure functions, so that rules out the possibility of 
> indirectly accessing mutable data via a function or method call.  So the 
> only case that needs to be checked is directly referencing such a mutable 
> field.

Thanks Bill, this is exactly what I'm trying to say :)

> It does seem like something that could be tacked on after the rest of 
> const/invariant/pure is done, though.  Much like C++'s mutable was.

Absolutely, but I'd at least like Walter to stop saying that transitive 
const (read, transitive *keyword* const) is neccessary for pure functions :) 
If he says "Oh yeah, I guess transitive const isn't necessary, but it's not 
a priority to fix it right now", then I'd be happy.

-Steve 





More information about the Digitalmars-d mailing list