Re: Re: vote on assignments as expressions

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Paul Prescod wrote:

> I almost think I would purposely use it everywhere, for two reasons:
>
>   1) consistency between different contexts
>
>   2) because it has always irritated me that programming languages use
> "==" to mean what mathematicians call "=" and "=" to mean something
> that mathematicians rarely do.

That bothers me.  What are newbies going to think when they see your code
posted with := and other's code posted with = ?

This is an unacceptable problem.  I can think of three solutions...

1) Have the interpreter throw an exception when := is the last operation on
a line.

2) Replace = with := for regular assignments.

3) Not add this assignment-as-expression feature

I gave some thought to how = ended up as an assignment operator.  Fortran is
the oldest usage I know of.  My guess is that they were thinking "make a = b
at the end of the operation".  Fortran stands for Formula Translation so
they were definitely thinking of math.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.