The stately := operator feature proposal

Jonathan M Davis jmdavisProg at gmx.com
Thu May 30 01:50:14 PDT 2013


On Thursday, May 30, 2013 09:43:36 Russel Winder wrote:
> On Thu, 2013-05-30 at 02:19 +0200, MrzlganeE wrote:
> […]
> 
> > In places where I write a bunch of short mathy code, I do not
> > want to use 'auto'. The := operator would allow to declare a
> > variable, deduce its type, and define its value.
> > 
> > void main() {
> > 
> >      x := 1;
> >      y := 2.0;
> >      z := x * y;
> >      y = 3.0;
> > 
> > }
> 
> […]
> 
> >      for (i := 0; i < 24; i++) {
> >      }
> 
> Go does exactly this, and it is good.
> 
> Less is more.

Less would mean not having this syntax, because it would be adding more to the 
language and therefore increasing its complexity.

Personally, I don't think think that the extra complication caused by having 
another syntax for something that we already have is worth it, regardless of 
whether it's aesthetically pleasing or not.

And honestly, I actually think that it would make code _less_ legible. Sure, 
other languages use this syntax, but the difference between = and := is minor, 
and we already have auto. So, this adds no functionality whatsoever.

- Jonathan M Davis


More information about the Digitalmars-d mailing list