Shared pain
Steve Teale
steve.teale at britseyeview.com
Fri Nov 19 23:04:55 PST 2010
On Fri, 19 Nov 2010 16:21:41 -0500, Jason House wrote:
> Steve Teale Wrote:
>
>> On Fri, 19 Nov 2010 08:25:17 -0500, Jason House wrote:
>>
>> > A cast to immutable is required when constructing immutable objects.
>> > The type system can't prove that's safe. It's a design limitation to
>> > keep complexity low.
>> >
>> Jason,
>>
>> But design limitations like that will force programmers who are on a
>> tight schedule to just say __gshared, and to hell with it.
>>
>> Languages can't be designed just on theory - some recognition of
>> practicality is also required.
>
> I didn't say I liked the need for the cast or even that I think D has
> the proper design! IIRC, the cast with object creation was in lieu of
> adding "unique" tepe qualifier and the extra complexity to get that
> right. In your example, I believe the object was created once, so a cast
> really isn't that bad. The bad part to me was the need to cast away
> immutability with every use. That's why I encouraged a bugzilla entry. I
> did't check this case, but Phobos had a bad track record with adopting
> type qualifiers after they were added to D2.
I'm a bit calmer now I have got most of my utility modules working again.
There were two circumstances where I found the casts particularly irksome.
I had at one point an immutable char* that I would be passing to Win32
functions. I was assigning to it the address of a plain static character
array, and I had to use a cast to do it. I could not see what harm such
an assignment could do.
Then I had a slew of cases where I had created immutable RegExp objects,
and I had to do (cast(RegExp) rexobj).find(...). I could not see what the
cast was protecting here either.
I think these are bugs, if you agree I will put them in bugzilla.
More information about the Digitalmars-d
mailing list