const(Object)ref is here!

Michel Fortin michel.fortin at michelf.com
Tue Dec 7 11:56:33 PST 2010


On 2010-12-07 12:54:49 -0500, Michel Fortin <michel.fortin at michelf.com> said:

> On 2010-12-07 11:09:50 -0500, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> said:
> 
>> On 12/6/10 9:56 AM, Michel Fortin wrote:
>>> On 2010-12-06 00:16:27 -0500, Graham St Jack
>>> <Graham.StJack at internode.on.net> said:
>>> 
>>>> First, I have to say that it is wonderful that someone is taking a
>>>> serious look at this area again, and even better, you have come up
>>>> with a compiler patch to make it happen!
>>>> 
>>>> Some questions (assuming your patch or something like it gets into dmd):
>>>> 
>>>> Does this mean that I would be able to write this:
>>>> immutable(Foo)ref foo; // create a reference
>>>> foo = new immutable(Foo)(); // re-bind it (not sure about "new" syntax
>>>> for immutables)
>>> 
>>> That's the whole point yes. This syntax works with my patch. :-)
>>> 
>>> 
>>>> Are there any other show-stopping syntax issues that are holding up
>>>> widespread adoption/rollout of const-correctness?
>>> 
>>> Surly there are others issues to solve. But this one is the one I kept
>>> falling into when trying to use immutable objects in my code some time ago.
>>> 
>>> 
>>>> What do Walter and Andrei think?
>>> 
>>> That I'd like to know.
>> 
>> I think actually offering a patch is a great initiative! I think the 
>> syntax is not all that intuitive, but it's great to experiment with. 
>> Michel, I suggest you put together some documentation (instead of 
>> implicitly referring to an earlier newsgroup discussion) so the 
>> community knows what to expect from the patch.
> 
> The patch itself is documented in the bug tracker where it resides. It 
> lacks some details about the internal implementation, but beside that 
> I'm not sure how more elaborate the documentation should be. D's 
> documentation doesn't tell about every corner case of the language 
> either.
> <http://d.puremagic.com/issues/show_bug.cgi?id=5325>
> 
> 
>> Also providing precompiled binaries would help people who don't care to 
>> build their own compiler.
> 
> I can easily provide one for Mac OS X. Can someone else build it for 
> Linux and Windows?

Here is a Mac OS X build. It's based on SVN revision 780 (two days 
old). It's a debug build so it might run a little slower than release 
versions of the compiler.
<http://michelf.com/docs/d/dmd-rev780-objconst.zip>

You should be able to use it with druntime either from DMD 2.050 or the 
latest SVN (nothing needs to be patched in druntime). Phobos unittests 
will pass (except for Rebindable tests, Rebindable itself works fine 
but some assertions the unittests aren't expecting the new type).

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list