logical const is a subset of transitive const

Steven Schveighoffer schveiguy at yahoo.com
Mon Sep 17 09:53:12 PDT 2007


"Bruce Adams" wrote
> Steven Schveighoffer Wrote:
>> BTW, if we get rid of invariant for functions meaning the same thing as
>> const functions, I think pure should be replaced with invariant.  It 
>> makes
>> more sense to me as an intuitive keyword.  An invariant function cannot
>> change anything and can only access invariant data, and call other 
>> invariant
>> functions.  Makes a lot of sense to me...
>>
>> -Steve
>>
> Pure is a good intuitive name to use for several reasons.
> For a start it has exactly the same meaning as its counterpart in 
> Fortran-90. If it exists in any functional languages out there most likely 
> they use the same terminology.

I agree, using the same terminology is a good thing.  I personally don't use 
functional programming, so I could care less what the keyword is as I 
probably will not use it.  I was just pointing out that 'invariant' to me 
means 'cannot change anything whatsoever' *intuitively* more than pure does. 
I understand the reasoning behind using pure as a keyword, but for someone 
who doesn't use FP, it is not as intuitive.  For example, it could be taken 
to mean 'free from defects', which would be a very arrogant declaration 
indeed :)

In any case, I've re-examined what invariant functions mean, and now I 
understand that there are *both* const and invariant functions, and they 
mean two separate things.  Since my argument to change 'pure' to 'invariant' 
was based on the belief that const functions were described with the 
'invariant' keyword to get around syntax requirements, my argument is no 
longer valid.

So I take it back, you can have pure :)

-Steve 





More information about the Digitalmars-d mailing list