[dmd-beta] dmd 2.064 beta take 2

Daniel Murphy yebblies at gmail.com
Wed May 15 12:05:16 PDT 2013


In a struct with multiple constructors, it could make sense to give an
immutable field a default value.


On Thu, May 16, 2013 at 5:02 AM, Walter Bright <walter at digitalmars.com>wrote:

>
> On 5/15/2013 11:30 AM, Andrei Alexandrescu wrote:
>
>> On 5/15/13 2:00 PM, Walter Bright wrote:
>>
>>>
>>> On 5/15/2013 7:39 AM, Andrei Alexandrescu wrote:
>>>
>>>> On 5/15/13 10:01 AM, Don Clugston wrote:
>>>>
>>>>> I think the new behaviour is a misfeature, and nothing more. It makes
>>>>> no
>>>>> sense to store a value in each struct, when the value is exactly the
>>>>> same every time.
>>>>>
>>>>
>>>> Consider:
>>>>
>>>> struct A
>>>> {
>>>> const int x = 7;
>>>> this(int y) { x = y; }
>>>> }
>>>>
>>>
>>> I think that should not be allowed, because x is const and is being
>>> initialized twice.
>>>
>>
>> There's a default and there's an explicit initializer. We could disallow
>> that but it wouldn't be terribly sensible.
>>
>
> I believe it was disallowed in earlier D2 versions. If I saw such code in
> a project, I'd find it awfully suspect, not sensible.
>
> ______________________________**_________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/**mailman/listinfo/dmd-beta<http://lists.puremagic.com/mailman/listinfo/dmd-beta>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20130516/d52a04d2/attachment.html>


More information about the dmd-beta mailing list