colon-equal vs equal 
Author Message
 colon-equal vs equal

How did the := come into being in languages like Algol, Pascal, and Ada?
I still prefer the way it is in C (and a little lesser so in Rexx and
fortran).  My second beef against := is the extra character.  My FIRST
beef against := is the KeYbOaRd ShIfTiNg I hAvE tO kEeP dOiNg FoR iT.



Wed, 19 May 1993 21:36:00 GMT  
 colon-equal vs equal

Quote:

>How did the := come into being in languages like Algol, Pascal, and Ada?
>I still prefer the way it is in C (and a little lesser so in Rexx and
>Fortran).  My second beef against := is the extra character.  My FIRST
>beef against := is the KeYbOaRd ShIfTiNg I hAvE tO kEeP dOiNg FoR iT.

----------

I don't know how the := came into being, but I don't have any beef
about it.  In fact, I think Pascal use of it is good.  Pascal uses =
as a boolean operator and := as asignment.  First, := seems better
since  i = i + 1 looks real funny.  Also, a nice feature is that
'if ( i := 10 )' will produce a syntax error in Pascal while
'if ( i =  10 )' will produce an assignment in C, usually not
intended.  FORTRAN uses .EQ. to make sure that there is no mixup
between the assignment operator and the comparison operator.  Perhaps
i <- 10 would make more sense than := although it is slightly more
awkward to type.  Typing the extra character is not that hard and more
than pays for itself by eliminating the occasional typo in Boolean
expressions.

rich katz
hewlett packard
p o box 7050
colorado springs, co
80933-7050




Wed, 19 May 1993 18:09:00 GMT  
 colon-equal vs equal

Quote:

> How did the := come into being in languages like Algol, Pascal, and Ada?

It originated with ALGOL-60. The European `{*filter*}-and-discipline' school of
language design (the people who brought you Algol-68, Pascal, Modula, Ada, and
Modula-2 and are now having yet another try at getting their mistakes right in
Modula-3) likes to claim apostolic descent from that language, and
they've retained := and some of its other crotchets.
--
      Eric S. Raymond                     (the mad mastermind of TMN-Netnews)

      Post: 22 S. Warren Avenue, Malvern, PA 19355      Phone: (215)-296-5718


Wed, 19 May 1993 20:02:00 GMT  
 colon-equal vs equal
I understand that the := was an attempt to draw a left-arrow on
a card punch.  Nowadays, it would be <-, but having no less-than sign,
:= was chosen.  I could dig up the reference if anyone cares.  - Darren


Wed, 19 May 1993 20:35:00 GMT  
 colon-equal vs equal

Quote:
>How did the := come into being in languages like Algol, Pascal, and Ada?

IAL 58.

Quote:
>I still prefer the way it is in C (and a little lesser so in Rexx and

Booooo! Hisssss!

It's all in how you read it. I read `a:=b' as `a becomes b' not `a equals b.'
`a equals b' is `a=b.'

So what about the shift-key? We're all touch-typists, rught?
--
As Loki walked with Othin wise,                                      -- s m ryan
with Hoenir under summer skies,                                
they found a river swift and deep.                              -- Andwari's Gem
They followed whither waters leap.                                        -- 1/2



Wed, 19 May 1993 01:16:00 GMT  
 colon-equal vs equal

Quote:


>>How did the := come into being in languages like Algol, Pascal, and Ada?

>I don't know how the := came into being, but I don't have any beef
>about it.  In fact, I think Pascal use of it is good.  Pascal uses =
>as a boolean operator and := as asignment.

Why not think of the ":=" versus "=" question as a choice of whether
or not to support operator overloading in the language.  The "=" for
assignment is a procedure, while the boolean operator is a function.

Whether or not you like operator overloading, I think that the ":="
versus "=" question is reducible to another more basic question and
should be discussed in that light.

Of course, everything in this posting could be wrong.

J Dana Eckart         UUCP: ...!(gatech | pyrdc)!gmu90x!dana
                            ...!pyrdc!nowhere!dana

                     SNAIL: P.O. Box 236/Fairfax, VA  22030-0236



Wed, 19 May 1993 15:58:00 GMT  
 colon-equal vs equal

Quote:

>First, := seems better since i = i + 1 looks real funny.

C's solution to that is to introduce ``i += 1''.  (Well, C didn't invent this
I don't believe but it has it.)

Quote:
>Also, a nice feature is that 'if ( i := 10 )' will produce a syntax error in
>Pascal while 'if ( i = 10 )' will produce an assignment in C, usually not
>intended.

No, this is not because of the different characters which make up the
operator.  This is because in C an assignment statement is an expression
and in Pascal it is not.  This is a completely separate question.  (I
personally think ``assignment'' and ``embedded assignment'' operators
should look different, something I've never seen in the real world.)

ajr

--
"The goto statement has been the focus of much of this controversy."
            -- Aho & Ullman, Principles of Compiler Design, A-W 1977, page 54.



Wed, 19 May 1993 23:36:00 GMT  
 colon-equal vs equal

Quote:

> as a boolean operator and := as asignment.  First, := seems better
> since  i = i + 1 looks real funny.  Also, a nice feature is that
> 'if ( i := 10 )' will produce a syntax error in Pascal while
> 'if ( i =  10 )' will produce an assignment in C, usually not
> intended.  FORTRAN uses .EQ. to make sure that there is no mixup

This has nothing to do with :=/= versus =/==. This has to do with C being an
expression-based language and Pascal being a statement-based language. There
are expression-based languages which use := and allow you to say things like
"if flag := f1 and f2 then...".

Just so long as you have two tokens. If you want to flame a language, try
BASIC ("if a = b then a = c"... the first is a comparison, the second an
assignment).
--
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.


Opinions may not represent the policies of FICC or the Xenix Support group.



Wed, 19 May 1993 06:12:00 GMT  
 colon-equal vs equal

Quote:

>I don't know how the := came into being, but I don't have any beef
>about it.  In fact, I think Pascal use of it is good.  Pascal uses =
>as a boolean operator and := as asignment.  First, := seems better
>since  i = i + 1 looks real funny.

It looks funny to me, too.  I much prefer "i += 1", but I don't remember
augmented assignment being legal in Pascal.

Quote:
>Also, a nice feature is that
>'if ( i := 10 )' will produce a syntax error in Pascal while
>'if ( i =  10 )' will produce an assignment in C, usually not
>intended.

This really has nothing to do with ":=" vs "=".  C is an
expression-based language; Pascal is not (by expression-based I mean
that every operator returns a value that can be used as one of the
parameters for another operator).  In Pascal, just about (ie, I'm not
100% sure :-)) every use of ":=" could be replaced by "=" with no
ambiguities arising (please don't flame me if there is an exception to
this statement; it would not be difficult to change the language so that
none of these ambiguities arise).  Heck, even my TRS-80 Model I Level II
BASIC could differentiate between these two cases! :-)
--



Wed, 19 May 1993 01:29:00 GMT  
 colon-equal vs equal

Quote:

>This really has nothing to do with ":=" vs "=".  C is an
>expression-based language; Pascal is not (by expression-based I mean
>that every operator returns a value that can be used as one of the
>parameters for another operator).

OK, you get the grumble instead of Peter :-)

Since you're defining your own term, I can't flatly say you're wrong,
BUT this definition of "expression based" contradicts every other
definition I'm familiar with.  C and Pascal are both statement based
languages, however C has a larger set of legal expressions.  BLISS and
Lisp are both expression based languages, I.E. everything is an
expression and returns a value.  

If C was an expression based language, the ?: expression would be
totally redundant with a normal if statement (of course it would
still be more compact).  If C was an expression based language the
following would be legal:

   foo = switch (bar) {
            case 'a': ...
            case 'b': ...
            default: ...
         };

This is not fantasy, the equivalent expressions exist and are useful
in BLISS and Lisp.
--
                                            dan

In real life: Dan Pierson, Encore Computer Corporation, Research
UUCP: {talcott,linus,necis,decvax}!encore!pierson



Wed, 19 May 1993 16:32:00 GMT  
 colon-equal vs equal

Quote:
>                             The European `{*filter*}-and-discipline' school of
>language design (the people who brought you Algol-68, Pascal, Modula, Ada, and
>Modula-2 and are now having yet another try at getting their mistakes right in
>Modula-3) ...                                                    

Not to start a flame war over this matter of taste, but a couple of points:

1. I personally think that "they" may finally have gotten it right
   with Modula-3.  While the standard modules may need a bit more
   work, neither C nor C++ appeared at birth with complete standard
   libraries.  I think that world really needs a strongly typed
   language that is powerful, flexible, and efficient enough for
   production use while remaining portable and simple enough to be
   comprehensible and implementable.  I know it's heresy, but C is
   neither the most portable language around nor an all-around ideal
   language.  There are many areas in which a safer language is
   better.  While I'd miss the conciseness of C, I simply don't
   understand people who feel that being force to adhere to their own
   type abstractions intolerably cramps their style.  My experience is
   that all well written programs have a well (but maybe not
   explicitly) defined set of data types anyway, strongly typed
   languages simply protect against careless errors using these types.

2. "They" are neither European nor the same folks.  The Modula-3
   design team is more closely related to the people who created the
   Xerox Parc set of B&D languages which culminated in Cedar.  This is
   good both because Cedar looked like a very interesting system (the
   closest an Algol-descended imperative language has gotten to a Lisp
   environment) and because Wirth wasn't the designer.  Wirth has a
   history of designing 80% of a language and setting it free; the
   Modula-3 team made a serious attempt to design the whole thing
   before releasing it.
--
                                            dan

In real life: Dan Pierson, Encore Computer Corporation, Research
UUCP: {talcott,linus,necis,decvax}!encore!pierson



Wed, 19 May 1993 17:07:00 GMT  
 colon-equal vs equal
Another expression based language is Algol 68.  Not only is

a := case month
       in 31, if year mod 4 = 0 then 29 else 28 fi, 31, 30, 31, 30, 31, 31,
       30, 31, 30, 31 esac;
legal, but so is

if a=b then a else c fi := d;

and they can be abbreviated to
a := (month|31, (year mod 4 = 0|29|28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

and
(a=b|a|c) := d;
respectively.  (And who said C could be terse and unreadable?)



Wed, 19 May 1993 16:27:00 GMT  
 
 [ 148 post ]  Go to page: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

 Relevant Pages 

1. One and One doesn't equal two It equals 1 - The Who

2. One and One doesn't equal two It equals 1 - The Who

3. equal vs. equalp

4. Using greater than or equal comparison. The equal is not...

5. Float>>equals: changed in 4.0

6. re equal on characters

7. apl equal on characters

8. Percent and Equal Signs

9. counting equal lines

10. TBFinder or equal tool

11. not equals?

12. A doesn't equal B, but B=A

 

 
Powered by phpBB® Forum Software