keywords "objconst" and "objimmutable" vs. const(Object) ref

Steven Schveighoffer schveiguy at yahoo.com
Wed May 18 05:05:55 PDT 2011


On Wed, 18 May 2011 02:20:16 -0400, Christopher the Magnificent  
<ultimatemacfanatic at gmail.com> wrote:

> On 5/17/11 9:07 PM, Michel Fortin wrote:
>> For
>> another, it's perfectly in line with how you do it for pointers. Also,
>> it'll work for 'shared' and 'inout' too (once 'inout' works properly).
>
> Are you saying that objconst and objimmutable would NOT work for shared  
> and inout?  Why is that?

inout and shared are the same thing as const and immutable, they are type  
modifiers.  So following your scheme, we need objshared and objinout  
keywords.  Not only that, but shared is orthogonal to  
inout/const/immutable, so if you wanted a rebindable reference to a shared  
const object, you'd need:

objconst objshared Object o;

Whereas with Michel's proposal, it's

const(shared(Object)) ref o;

The argument from Walter will be that const is complicated enough, we  
don't need more keywords.  I know, because he's used that argument before  
:)  One of the only reasons inout made it into the language is because it  
was an existing (but defunct) keyword.

I tend to agree with him on that.  Doubling the keywords is not a good  
idea.

-Steve


More information about the Digitalmars-d mailing list