www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Tidy auto [Was: Re: disable]

reply Sean Kelly <sean invisibleduck.org> writes:
bearophile Wrote:

 Walter Bright:
 Andrei introduced me to that style, and I'm starting to use it more and 
 more. I like it for the reasons you state.

I'm not using it because I'm not using D2 much yet, but I have read that a good number of people are adopting that style in other languages as Scala, so it can be a good way to program (I can appreciate it myself). If this is true then a syntax like: auto immutable x = y * 2; can be seen as too much long and boring to write all the time, so the "immutable" keyword may need to be changed again :-)

Fortunately, the "auto" keyword can be left out. "auto" is actually a storage class, it doesn't directly mean "infer the type."
Jan 18 2010
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Sean Kelly:
 Fortunately, the "auto" keyword can be left out.<

The point of my post was that I think that's bad. And I have tried to explain why. Bye, bearophile
Jan 18 2010
prev sibling next sibling parent reply Leandro Lucarella <llucax gmail.com> writes:
Sean Kelly, el 18 de enero a las 16:10 me escribiste:
 bearophile Wrote:
 
 Walter Bright:
 Andrei introduced me to that style, and I'm starting to use it more and 
 more. I like it for the reasons you state.

I'm not using it because I'm not using D2 much yet, but I have read that a good number of people are adopting that style in other languages as Scala, so it can be a good way to program (I can appreciate it myself). If this is true then a syntax like: auto immutable x = y * 2; can be seen as too much long and boring to write all the time, so the "immutable" keyword may need to be changed again :-)

Fortunately, the "auto" keyword can be left out. "auto" is actually a storage class, it doesn't directly mean "infer the type."

I was under that impression too, but that's not what my test show. You can write auto int x = 5;, it fails to compile with an error saying that x have both explicit type and auto. I find this very odd, I think auto should be a regular storage class. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- I've always been mad, I know I've been mad, like the most of us... very hard to explain why you're mad, even if you're not mad...
Jan 19 2010
parent Jesse Phillips <jessekphillips+D gmail.com> writes:
Leandro Lucarella wrote:

 Sean Kelly, el 18 de enero a las 16:10 me escribiste:
 bearophile Wrote:
 
 Walter Bright:
 Andrei introduced me to that style, and I'm starting to use it more and 
 more. I like it for the reasons you state.

I'm not using it because I'm not using D2 much yet, but I have read that a good number of people are adopting that style in other languages as Scala, so it can be a good way to program (I can appreciate it myself). If this is true then a syntax like: auto immutable x = y * 2; can be seen as too much long and boring to write all the time, so the "immutable" keyword may need to be changed again :-)

Fortunately, the "auto" keyword can be left out. "auto" is actually a storage class, it doesn't directly mean "infer the type."

I was under that impression too, but that's not what my test show. You can write auto int x = 5;, it fails to compile with an error saying that x have both explicit type and auto. I find this very odd, I think auto should be a regular storage class.

auto int foo = 5; Works fine for me, dmd 2.037
Jan 19 2010
prev sibling parent Leandro Lucarella <llucax gmail.com> writes:
Jesse Phillips, el 19 de enero a las 15:21 me escribiste:
 Leandro Lucarella wrote:
 
 Sean Kelly, el 18 de enero a las 16:10 me escribiste:
 bearophile Wrote:
 
 Walter Bright:
 Andrei introduced me to that style, and I'm starting to use it more and 
 more. I like it for the reasons you state.

I'm not using it because I'm not using D2 much yet, but I have read that a good number of people are adopting that style in other languages as Scala, so it can be a good way to program (I can appreciate it myself). If this is true then a syntax like: auto immutable x = y * 2; can be seen as too much long and boring to write all the time, so the "immutable" keyword may need to be changed again :-)

Fortunately, the "auto" keyword can be left out. "auto" is actually a storage class, it doesn't directly mean "infer the type."

I was under that impression too, but that's not what my test show. You can write auto int x = 5;, it fails to compile with an error saying that x have both explicit type and auto. I find this very odd, I think auto should be a regular storage class.

auto int foo = 5; Works fine for me, dmd 2.037

I only have LDC (based on DMD 1.051) and GDC (based on DMD 1.024) here, LDC fails with this message: /tmp/x.d(4): Error: variable x.main.x both auto and explicit type given And GDC works, so I think it might be a regression. I should test with the latest DMD... -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Que barbaridad, este país se va cada ves más pa' tras, más pa' tras... -- Sidharta Kiwi
Jan 19 2010