Add := digraph to D

Era Scarecrow rtcvb32 at yahoo.com
Wed Jun 20 19:24:00 PDT 2012


On Wednesday, 20 June 2012 at 17:19:08 UTC, Jonathan M Davis 
wrote:
> Not to mention, there are some programming languages (e.g. 
> Pascal) which use := for normal assignment, so it would be 
> confusing for anyone familiar with those languages.

  AutoIt or AutoHotKeys is one, where = and := do two very 
different things (and confusing for a first time user).

  As for the topic of discussion, I think := should not be used as 
it has very few useful cases, but also it's making two 
incompatible operators compatible.

Consider:

test:=5;
for(/*something*/) {
/*something*/

  b++;
  if (b > 10)
     goto test;
}

--

  In the example above, test:=5 should have been test: b=5. It may 
potentially hide even worse bugs, where currently := is illegal 
and easy to spot by a compiler error.

  Besides, isn't 'auto' short enough? as mentioned you may save 2 
characters. Not worth it. Be worse if you use it in two places 
and it's now trying to declare the same variable twice and 
there's nothing there suggesting it's being declared. One 
character is easy to miss or forget.

  The worst bugs I've gone against are usually the simplest, 
easiest and most subtle.


More information about the Digitalmars-d mailing list