Bryan Murdock wrote:
>> := is declare and assign
>>
>> = is assign
>>     
>
> I'm not a compiler guy, but I know dynamic languages like Python don't
> need to differentiate between those two cases.  Is it an aspect of
> compiled languages that require the distinction?
>   

My guess is that this syntax is a reaction to C++'s broken use of the 
'=' token.

In C++, this:

   MyClass c = foo;

And this:

   MyClass c;
   c = foo;

Are different.

In the first case, the copy constructor is called. In the second case, 
the default constructor *and* assignment operator is called. The problem 
is that C++ uses the '=' token to mean both assignment and 
initialization in different contexts.

The key is that a purely functional program will never use the second 
case. The Haskell guys know what this is all about. In Haskell, you can 
declare and initialize a variable, but never re-assign it. The language 
doesn't even have an assignment operator.

In my view, this is a smart move by Go.

--Dave

P.S. I'm not a real Haskell hacker, but I play one on mailing lists.
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to