Code behaves incorrectly if it is compiled in std.functional

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 8 06:11:16 PDT 2015


On Mon, 08 Jun 2015 14:28:06 +0200, Timon Gehr wrote:

> On 06/08/2015 09:28 AM, ketmar wrote:
>> On Sun, 07 Jun 2015 18:49:24 +0200, Timon Gehr wrote:
>>
>>> On 06/06/2015 08:06 AM, ketmar wrote:
>>>> On Sat, 06 Jun 2015 00:28:51 +0200, Timon Gehr wrote:
>>>>
>>>>> On 06/05/2015 02:33 PM, ketmar wrote:
>>>>>> i agree, i think it was a keyword used 'cause it was already used
>>>>>> in C.
>>>>>> but it's meaning is completely redefined in D.
>>>>>
>>>>> The meaning is exactly the same. It's the default storage class.
>>>>
>>>> then i'll fill a bug about `auto auto` and will reopen it until it's
>>>> fixed.
>>>>
>>>>
>>> This is valid C:
>>>
>>> int main(){
>>>     const auto int x=2;
>>>     return 0;
>>> }
>>>
>>> This is not valid C:
>>>
>>> int main(){
>>>     auto auto int x=2; return 0;
>>> }
>>>
>>> What is the problem?
>>
>> sorry, i didn't realized that this is NG for C language.
>>
>>
> This is valid D, but it is pointless:
> 
> int main(){
>      const auto x=2; return 0;
> }
> 
> int main(){
>      auto const x=2; return 0;
> }
> 
> 
> This is valid D:
> 
> int main(){
>      const x=2;
>      return 0;
> }
> 
> This is not valid D:
> 
> int main(){
>      auto auto x=2; return 0;
> }
> 
> int main(){
>      int const x=2; return 0;
> }
> 
> 
> This could be valid D, but isn't (assuming DMD behaves correctly here, I
> don't think this is documented), because it is pointless, and the
> compiler is now arbitrarily trying to be helpful:
> 
> int main(){
>      const auto int x=2;
>      return 0;
> }
> 
> The error message:
> tt.d(2): Error: variable tt.main.x storage class 'auto' has no effect if
> type is not inferred, did you mean 'scope'?
> 
> Note "storage class".
> 
> 
> Ditto:
> 
> int main(){
>      auto const int x=2;
>      return 0;
> }

so specifying two storage classes are sometimes valid and sometimes 
invalid. a perfect consistency!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150608/78bc9724/attachment.sig>


More information about the Digitalmars-d mailing list