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

Christopher the Magnificent ultimatemacfanatic at gmail.com
Tue May 17 19:06:39 PDT 2011


On 5/17/11 7:26 PM, Jesse Phillips wrote:
> Christopher the Magnificent Wrote:
>
>> Greetings all.  First time poster here.
>>
>> By way of introduction, my name is Christopher.  I've been fascinated
>> with D for a few years now.  My main programming language has been
>> Python, but I have used and studied many programming languages to some
>> extent.  I love to design things, like houses, pipe organs, and even
>> computer languages.
>
> Hello, and welcome.
>
>> Now I understand that another syntax has been nominated to do this job
>> which is the const(Object)ref syntax.  I dislike that syntax because
>> "const(Object)" means a constant variable referencing a constant data
>> structure, and "const(Object)ref" LOOKS like it should be a reference to
>> a variable of type "const(Object)" -- to me it suggests a variable
>> referencing a constant variable referencing a constant data structure.
>> "const(Object)ref" suggests TWO levels of pointers, but that is not the
>> meaning being ascribed thereunto.
>
> Syntax has definitely been a major problem for this feature. Walter's stance has been that he has tried many times to get the semantics and syntax to work and has given up. michelf (Sorry don't know his real name) has created a branch which implements the syntax you are against. As this is a change Walter is skeptical of it will take time to review.
>
> Now as for your distaste, I believe the intent is to make a valid declaration:
>
> Object ref foobar;
>
> Meaning that you are exposing the reference or address itself. However I think there might be more to it when considering generic code which would suggest these should also be valid forms:
>
> void function(T)(const(T) ref thing);
>
> const(int) ref foo;
> const(myStruct) ref bar;
> const(int*) ref bared;
>
> But that would suggest D has a reference type, and it doesn't. So in any case, this isn't simple and I'm not really sure how well const(Object) ref stands up to this kind of question.

Thanks for the background, Jesse Phillips.  Do you have any thoughts on 
my proposed objconst/objimmutable syntax, as to whether you think it is 
readable, intuitive, and just whether you like it or don't like it?


More information about the Digitalmars-d mailing list