Fixing const arrays

Michel Fortin michel.fortin at michelf.com
Sat Dec 10 15:20:08 PST 2011


On 2011-12-10 21:47:13 +0000, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> We decided to fix this issue by automatically shedding the top-level 
> const when passing an array or a pointer by value into a function.

It seems strange that if you implemented the exact same semantic as an 
a dynamic array or a pointer with a struct it wouldn't work. Basically, 
you're making a special case by giving two language-defined types 
characteristics that can't be replicated by user types. I'm not 
concerned that much, but I thought you worried about those things 
Andrei.

Also seems strange to me that class references aren't included in that 
list, but then I though about how tail-const still doesn't work with 
objects. You'd need my const(Object)ref patch to make that work, and 
Walter hasn't taken time to look at it yet…

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



More information about the Digitalmars-d mailing list