Pascal assignment notation vs. C#

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

From my days of programming Pascal in the early 1990s, I remember
using ":=" for assignment and "=" for equality, but someone else
remembers "=" and "==" just like C#. Does anyone remember?

You are right; he is wrong.
 
Hi Tim,

Digging very deep in my memory bank from the only time I ever used Pascal
(in 1996), I believe we used := for assignment, although I'm only 80% sure
of it. = would then be equality.
 
Hi,

:= and =

http://www.ictp.trieste.it/~manuals/programming/sun/pascal/lang_ref/ref_lex.doc.html#210

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Tim923 said:
From my days of programming Pascal in the early 1990s, I remember
using ":=" for assignment and "=" for equality, but someone else
remembers "=" and "==" just like C#. Does anyone remember?

-
http://mysite.verizon.net/vze8adrh/news.html (profile) --Tim923 My email
is valid.
 
Sriram Krishnan said:
Hmm..but I vaguely remember a LET statement which was meant to clear things
up

Yes, originally Basic syntax required "LET X = 5" for assignment.
However, as microcomputers dawned, and Basic programs had to fit into 4K
(that's kilobytes, not megabytes) of RAM, so the syntax got shortened, as
Basic interpreter (we don't need no stickin' compilers) realized that one
could always tell which was which.

Then came C, which tried it's best to allow assembler coding conventions
in a higher level language. And to pull that off, they need to allow
assignments in the middle of a while() statement. (*) Suddenly, you could
have an assignment & a comparison in the same context, and you needed a way
of telling them apart.


(*) Putting an assignment inside a if() statement is OTOH, completely
unnecessary, and is allowed in C programs (probably) just so early C
compilers could use the same expression evaluator for both if()s and
while()s.

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
 
From my days of programming Pascal in the early 1990s, I remember
using ":=" for assignment and "=" for equality, but someone else
remembers "=" and "==" just like C#. Does anyone remember?

Bringing this on-topic, I much prefer ':=' and '=' to '=' and '=='
(respectively).

A quick glance at Pascal's ':=' and there's no doubt in your mind that it's
an assignment. A quick glance at C's '=', and then another glance, and
/then/ you know.
 
I disagree. I personally have no problem with distinguishing either one.

Luckily for you, you're sharper than all those C-language programmers who
have had such trouble differentiating between C's equality and assignment
operators that they go so far as to writing the constant on the left-hand
side, in order that the compiler will flag an attempted assignment to it;
e.g.:

(5 == foo) /* correct */

or

(5 = foo) /* mistake -- flagged by compiler */
 
C# Learner said:
Bringing this on-topic, I much prefer ':=' and '=' to '=' and '=='
(respectively).

A quick glance at Pascal's ':=' and there's no doubt in your mind that
it's
an assignment. A quick glance at C's '=', and then another glance, and
/then/ you know.

I disagree. I personally have no problem with distinguishing either one.

:= just looks silly.
 
Which actually was a very, very usefull way to avoid hard to trace bugs.
I don't find it all that difficult to differentiate between
= and == but a typo is easily made, even more so if you're developing
both in Pascal and C ;)

Willem van Rumpt
 
Willem van Rumpt said:
Which actually was a very, very usefull way to avoid hard to trace bugs.
I don't find it all that difficult to differentiate between
= and == but a typo is easily made, even more so if you're developing
both in Pascal and C ;)

And of course, this is one reason why C# forces the type of expression
in an "if" statement to be bool...
 
Back
Top