[Issue 5984] add new keywords obj_const and obj_immutable to make it possible to declare mutable reference variables referencing const or immutable class instances

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 13 10:13:36 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5984



--- Comment #2 from Christopher the Magnificent <ultimatemacfanatic at gmail.com> 2011-05-13 10:09:30 PDT ---
Where do I find the "const(Object) ref" syntax described?  I've never run
across it in the D Language Reference.  Point me to some info about this
particular syntax and then I'll be able to comment on how my own syntax may be
superior.

(In reply to comment #1)
> How is this better than the 'const(Object) ref' syntax*?
> 
>     class A { ... }
> 
>     immutable(A) func(immutable A a1, immutable A a2) {
>         immutable(A) ref a_ptr = null;
>         ...
>     }
> 
> and
> 
>     const(ClassName)ref[] myArray;
> 
> Actually there is already std.typecons.Rebindable which mostly works (uglily):
> 
>     class A { ... }
> 
>     immutable(A) func(immutable A a1, immutable A a2) {
>         Rebindable!(immutable(A)) a_ptr = null;
>         ...
>     }
> 
> and
> 
>     Rebindable!(const(ClassName))[] myArray;
>     myArray.length = 1;
>     myArray[0] = constant_object;
>     myArray ~= rebindable(constant_object);
> 
> *: https://github.com/D-Programming-Language/dmd/pull/3

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list