# Dependence on Programming Experts

John Vokey vokey at uleth.ca
Thu Jul 13 01:55:14 EDT 2006

```A bit late in the debate (but I am at my cottage with at best
primitive dial-up):

On 11-Jul-06, at 8:29 PM, Dan wrote:

>
> I for one wish Rev had never compromised and begun using the equal
> sign as
> an assignment operator. Many (perhaps most) other languages
> disambiguate the
> confusing uses by some artificial construct. In Pascal, e.g.,
> assignment is
> :=. In C/C++ as I recall, equality is testred with == and some
> special type
> of equality is ===. Just syntactical crap.
>
> As Richard says, if this is an optional addition to the language, I
> guess
> I'd grudgingly -- VERY darned grudgingly -- look the other way. But
> I'd hold
> my nose at the same time.

I can't but disagree.  I have yet to find anyone with more than a few
minutes of experience who is confused by a statement such as `x=1'
*in context*.  Indeed, I would go so far as to advocate further that
even the logical variants of `x=1' have a numerical value (e.g., 0
for false, 1 for true) as in many languages (especially BASICs), so
that the logical value can be used directly in algebraic (and string)
expressions without having to work through a lengthy series of
logical conversions.  For example:

x = (z=x)*y # if z=x then x=y, else x=0; what could be simpler?

A good example of the silliness of over-emphasising the acontextual
distinction between assignment and logical statements is seen in the
programming/statistical system/language R (GNU's S): for years the
most common operation of assignment required the clumsy syntax

x<-1 # assign the value of 1 to x, almost as stupid as Pascal's x:=1

two-keystrokes (including a shift-key for one of the characters) for
the most common statement!  The usual comments were trotted out in
defence: ``but a statement such as x=1 is ambiguous, and confusing to
the user!''  Eventually, the keepers of R (all wonderful people of
surpassing brilliance and humanity) relented, and

x=1 # assign the value of 1 to x

was allowed as an *optional* variant of x<-1.  The average, or even
novice R user has no more problem interpreting such statements than
does the R parser/interpreter (which is never confused over this
issue).  And, in R the x<-1 syntax is even less arbitrary than in RR/
MC, because a reversal of the assignment arrow, x->y, also has a
unique meaning in R.  (One does note, though, that most R books still
use the x<-1 form, probably because they are written by my fellow
professorial colleagues who never miss an opportunity to evince
pedantry.)

Many other languages have at least recognised that lengthening the
assignment statement is inefficient, so instead have lengthened the
logical form, using such constructions as `x==1' for a test of
equality.  Again, though, as this is the most common form of the
logical test (i.e., equality is tested more often than most other
logical statements), it is inefficient, and, again, as it is always
clear from the context (and, note, therefore as simple to write the
interpreter for one form as the other), such requirements amount to
no more than pedantry and fussiness.

As noted, the solution is not to force a given syntax, but to offer
efficient shortcuts as options.  So, use put 1 into x if you want,
but allow for x=1 as an equivalent, but more efficient syntax.  After
all, RR/MC allows for regex expressions, and they are hardly
transparent or non-ambiguous to the novice (or even experienced!) user!

--
Please avoid sending me Word or PowerPoint attachments.
See <http://www.gnu.org/philosophy/no-word-attachments.html>

-Dr. John R. Vokey

```