Logical const

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Dec 3 05:00:43 PST 2010


On 02/12/2010 21:04, Steven Schveighoffer wrote:
> On Thu, 02 Dec 2010 13:57:04 -0500, Bruno Medeiros
> <brunodomedeiros+spam at com.gmail> wrote:
>
>> On 29/11/2010 14:56, Steven Schveighoffer wrote:
>>> This has been discussed at length on this newsgroup, and I argued for it
>>> for a long time. You will not get any traction with Walter, because
>>> I've already proven that logical const == const, and it still doesn't
>>> change his mind.
>>
>> Could you detail a bit what do you mean by logical const == const ?
>> That doesn't sound right to me.
>>
>
> Here is where I show how logical const already exists, it's just clunky
> to use.
>
> BTW, this was before TLS, so the example would have to be updated a bit.
>
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=58927
>
>
> -Steve

Ok. Well, for starters the "const" functions that mutate the object 
state cannot be pure. (if you manage to mutate it without casts in a 
pure function, it's because of a compiler bug)
Second, there's the TLS thing. I don't think you can just "update it a 
bit", there would be significant changes, maybe not in code size, but in 
runtime effect: You would need to make it global shared, and thus have 
to synchronize the access to the _mutable global. This is quite significant.

The above are not trivial differences, so I do not agree that it 
constitutes full logical const, only a limited form of it. More 
concretely, it doesn't constitute logical const in in the sense where 
you can use that as argument to say "logical const already exists, it's 
just clunky to use", so let's add it to the language formally. Like if 
mutable members where just syntax sugar, or a betterment of safety rules.


There is one thing however that doesn't feel right in all of this, with 
regards to passing immutable objects to other threads. But I think I 
need to read TDPL concurrency chapter to clarify some things first of all.

-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list