What assignment and equivalence syntax do you prefer?

  • Follow


What assignment and equivalence syntax do you prefer?

Not that you have much choice when you use a given language:

If it's C its a=1 and a==1
if it's pascal its a:=1 and a=1
if it's BASIC its a=1 and a=1  (huh?, but yes it is)

And there's more...

But do you have a preference?  And why?

btw, i quite like proper BASIC (not these 'street basics'!)

LET a=1
IF a=1

pretty clear, that, but once you omit the keyword 'LET' it loses some
of that clarity (IMO).
0
Reply gswork (648) 10/10/2003 12:14:36 PM

gswork@mailcity.com (gswork) writes:

> What assignment and equivalence syntax do you prefer?
>
> Not that you have much choice when you use a given language:
>

Sometimes you do, since there are so many possible types of
equivalence.  I'm rather satisfied with

(setf place value)

and

(eq x y) or (eql x y) or (equal x y) or (equalp x y) or etc. depending
on the type of equivalence I need.

-- 
Howard Ding
<hading@hading.dnsalias.com>
0
Reply hading (66) 10/10/2003 12:19:33 PM


gswork@mailcity.com (gswork) wrote:
> What assignment and equivalence syntax do you prefer?

I prefer...

> if it's pascal its a:=1 and a=1

The single = should retain it's meaning from mathematics, IMO.
I've no great feeling about what's the best assignement operator, except
that it shouldn't be just =.

/me hands in his C club membership card.

> pretty clear, that, but once you omit the keyword 'LET' it loses some
> of that clarity (IMO).

First time I saw x=y without a LET, I thought it was some sort of assert.

"The programmer typed x=1. He made a statement that x and 1 are equal."
(Looks back through the code.) "But x cannot be 1 at this point. Perhaps
the programmer wants the ON ERROR block to run here."

With the keyword LET, it's a bit clearer. LET x=1 tells the computer to
change the state of play so that x=1 is a true statement.

It could be argued that for
LET x=y
it's a valid interpretation to write over y with x, or even just set both x
and y to zero.

Howabout...
LET x*2=12       (Assign 6 into x)

In short, my problem with the = symbol for assignment is that equality is
merely a side effect of the act of copying. The idea assignment operator,
for me, should be something that implies making a copy which replaces the
old contents.

What that symbol should be, I don't know.

Bill, more equal than others.

-- 
   The address in the reply to header is correct, but I'll
   read it quicker if you drop the word "usenet".
0
Reply billg-usenet (97) 10/10/2003 12:43:20 PM

In article <20031010084320.667$I1@newsreader.com>, Bill Godfrey wrote:
> gswork@mailcity.com (gswork) wrote:
[cut]
> Howabout...
> LET x*2=12       (Assign 6 into x)
> 
> In short, my problem with the = symbol for assignment is that equality is
> merely a side effect of the act of copying. The idea assignment operator,
> for me, should be something that implies making a copy which replaces the
> old contents.
> 
> What that symbol should be, I don't know.

When teaching entry level C++ a couple of years ago, I had from
time to time students that were initially confused about what
side of the '=' the object (the thing being assigned to) went.

Some wanted to write "2 = x"  as in "assign 2 to x".

A better syntax would possibly be

    x <- 2




-- 
Andreas K�h�ri
0
Reply usenet12 (188) 10/10/2003 12:51:14 PM

billg-usenet@bacchae.f9.co.uk.invalid (Bill Godfrey) wrote:

>gswork@mailcity.com (gswork) wrote:
>> What assignment and equivalence syntax do you prefer?
>
>I prefer...
>
>> if it's pascal its a:=1 and a=1
>
>The single = should retain it's meaning from mathematics, IMO.
>I've no great feeling about what's the best assignement operator, except
>that it shouldn't be just =.
>
>/me hands in his C club membership card.

IMHO one doesn't have to love each and every part of the C language 
to be(come) a member of the C club (at least I hope so... :) ).

<SNIP>
-- 
Irrwahn 
(irrwahn33@freenet.de)
0
Reply irrwahn33 (608) 10/10/2003 1:50:18 PM

Bill Godfrey wrote:

<snip>
> 
> The single = should retain it's meaning from mathematics, IMO.
> I've no great feeling about what's the best assignement operator, except
> that it shouldn't be just =.

Which meaning, from which mathematics?  The way I was taught algebra, 
all those years ago, 'x=y' was an assignment.  Then when I was learning 
simple logic, 'x=y' was an equality test.

Sticking to the simplest form, 'a=b+c' is quite readable to anyone who's 
done simple algebra.  It doesn't (or shouldn't) take long to figure out 
why 'if (x=y)' is an assignment, and that another token is required for 
equality testing.  With that in mind, '==' is as good a token as any :>

-- 
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

0
Reply emonk (360) 10/10/2003 1:53:36 PM

Andreas Kahari <ak+usenet@freeshell.org> wrote:
> A better syntax would possibly be
>     x <- 2

if (x<-2) { printf("x is less than -2\n"); }

I know what you mean though. I like "arrow" imagery. x <: 2 perhaps?

Bill, making a symbolic gesture.

-- 
   The address in the reply to header is correct, but I'll
   read it quicker if you drop the word "usenet".
0
Reply billg-usenet (97) 10/10/2003 1:54:11 PM

In article <20031010095411.589$wT@newsreader.com>, Bill Godfrey wrote:
> Andreas Kahari <ak+usenet@freeshell.org> wrote:
>> A better syntax would possibly be
>>     x <- 2
> 
> if (x<-2) { printf("x is less than -2\n"); }

It's a s bad as

    if (x=0) { printf("x is 0\n"); }

> I know what you mean though. I like "arrow" imagery. x <: 2 perhaps?

Yes, like an arrow.  You even see it in algorithm descriptions
in print sometimes.  Hmmm... no, "<:" lacks the arrowness.  What
about "�"?  Maybe it's too non-ASCII?  You could also make a
distinction between the em-dash and the shorter en-dash (for
negation), but again, that's outside ASCII (and makes the code
hard to read).

I'm sure someone must have had this discussion before... at a
language commitee meeting or something (or in a coffee room at
AT&T).



-- 
Andreas K�h�ri
0
Reply usenet12 (188) 10/10/2003 2:10:16 PM

Corey Murtagh <emonk@slingshot.co.nz.no.uce> wrote:

> Which meaning, from which mathematics?

The way I was taught in school. No other meanings have any relevance. My
perseption is all important.
<g>

> The way I was taught algebra,
> all those years ago, 'x=y' was an assignment.

That's odd. I was taught in algebra that 'x=y' was a statement of equality.
x and y have always existed and they always have had an equal but
unspecified value.

> Then when I was learning
> simple logic, 'x=y' was an equality test.

I've always called that algebra. (Although it's also simple logic.)
I've been wrong about this sort of thing before, so everyone, read some
followups.

> Sticking to the simplest form, 'a=b+c' is quite readable to anyone who's
> done simple algebra.

Yes, it's making an *indempotent statement* that a has the same value as
the sum of b and c.

Crucially, (in the world of algebra) it would not change the value of a,
but just give you a clue about a's value.

> It doesn't (or shouldn't) take long to figure out
> why 'if (x=y)' is an assignment,

We both know that, but to someone who is unfamiliar with C, they may
conclude it's perfectly reasonable test for equality.

> and that another token is required for
> equality testing.  With that in mind, '==' is as good a token as any :>

== is reasonable for equality test operator. My main issue is that the
imagery of the assignment operator should be more about copying. Use of =
for assignment reads like "Do something to make this equality statement
true", which is arguably open to interpretation.

If = is no longer used for assignment, we may as well save a keystroke for
the equality operator.

Of course, it doesn't really matter, so long as we all agree which is
which. If DMR said that &%% is assignment and @=# is equality, that's
what's we'd be using now.

Bill, if !x@=#y^ :@ printf!%Hello World\n%^< (!

-- 
   The address in the reply to header is correct, but I'll
   read it quicker if you drop the word "usenet".
0
Reply billg-usenet (97) 10/10/2003 2:21:02 PM

Andreas Kahari wrote:

> A better syntax would possibly be
> 
>     x <- 2

I think the left-to-right movement (of the data) might be a source
of confusion (particularly in the original x=2).

Why not:

	2 -> x

-- 
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|
0
Reply Chris7 (2511) 10/10/2003 4:49:54 PM

"Howard Ding " wrote:

>> What assignment and equivalence syntax do you prefer?
> 
> (setf place value)

In BOOL:
		set: object new-value

> (eq x y) or (eql x y) or (equal x y) or (equalp x y) or etc.

		eq: object object

-- 
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|
0
Reply Chris7 (2511) 10/10/2003 4:53:13 PM

On Sat, 11 Oct 2003 02:53:36 +1300, Corey Murtagh wrote:

> Bill Godfrey wrote:
> 
> <snip>
>> 
>> The single = should retain it's meaning from mathematics, IMO.
>> I've no great feeling about what's the best assignement operator, except
>> that it shouldn't be just =.
> 
> Which meaning, from which mathematics?  The way I was taught algebra, 
> all those years ago, 'x=y' was an assignment.

If that's true, then you had incompetent mathematics teachers. Maybe
they figured the only way anyone would pass the SAT is to explain y=x*x
as an algorithm for plotting a parabola instead of as a mathematical
relation.

Did your teachers really try to tell you that

  (x*x) - 4 = 0

ASSIGNS +2 or -2 to x, or did they say this means that x EQUALS +2 or
x EQUALS -2? How do you assign "+2 or -2" to a variable anyway?


0
Reply sheldonsimms (452) 10/10/2003 7:04:31 PM

gswork wrote:

> But do you have a preference?  And why?

I've thought about it since I saw your question....

.....and apparently I don't.

[shrug]

It is, indeed, one of the distinquishers between languages and
interesting to me on that basis, but I have no favorites.  As
you say, you use what a language provides.  When designing a
language I use whatever strikes my fancy at the time.  I tend
(but only slightly) to use := in grammer documents, but I intend
it to mean "is defined as" (so I'm using a usual assignment op
in an "equality" sense! :-).

Come to think of it, I used "=" for assignment in the last two
languages I wrote compilers for (correction: last two PROGRAMMING
languages).  Here's the ironic part: I've already been bit in
my latest compiler project when, several times, I used "=" where
I meant "==" in the test input files (the real irony is it almost
never happens when I program in C or C++ or any other language...
just my own simple programming language!).

This may well be an argument for me to consider other assignment
and equality ops!!

The language previous to this one used pre-fix notation and had
no equality operation (it was a math expression evaluator), so
there was no chance for confusion:

	= $a pow 2 64	"set $a to 2^64"


-- 
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|
0
Reply Chris7 (2511) 10/10/2003 7:42:10 PM

Bill Godfrey wrote:

> Corey Murtagh <emonk@slingshot.co.nz.no.uce> wrote:
> 
>>Which meaning, from which mathematics?
> 
> The way I was taught in school. No other meanings have any relevance. My
> perseption is all important.
> <g>

:>

>>The way I was taught algebra,
>>all those years ago, 'x=y' was an assignment.
> 
> That's odd. I was taught in algebra that 'x=y' was a statement of equality.
> x and y have always existed and they always have had an equal but
> unspecified value.

Ah, memory failed me.  You're right, and I was coloring my memory with 
programming pejudice.  I retract my earlier statement :>

-- 
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

0
Reply emonk (360) 10/10/2003 10:00:13 PM

On Sat, 11 Oct 2003, Corey Murtagh wrote:
>
> Bill Godfrey wrote:
> > Corey Murtagh <emonk@slingshot.co.nz.no.uce> wrote:
> >
> >>The way I was taught algebra,
> >>all those years ago, 'x=y' was an assignment.
> >
> > That's odd. I was taught in algebra that 'x=y' was a statement of equality.
> > x and y have always existed and they always have had an equal but
> > unspecified value.
>
> Ah, memory failed me.  You're right, and I was coloring my memory with
> programming pejudice.  I retract my earlier statement :>

Well, it could be said that

   f(x) = x^2

is an "assignment."  Sort of.

-Arthur

0
Reply ajo (1601) 10/10/2003 10:32:40 PM

Programmer Dude wrote:
> Andreas Kahari wrote:
> 
> 
>>A better syntax would possibly be
>>
>>    x <- 2
> 
> 
> I think the left-to-right movement (of the data) might be a source
> of confusion (particularly in the original x=2).
> 
> Why not:
> 
> 	2 -> x
> 

That's how it is on those TI graphing calculators, except it's a solid
triangle.  I think it makes more sense because it flows from left to
right.  But people say it's better to put the "most important" symbol
on the left side of the statement, which kinda makes sense too.

0
Reply bleah-no-more-spam (13) 10/11/2003 1:52:21 AM

"Andreas Kahari" <ak+usenet@freeshell.org> wrote:
> In article <20031010095411.589$wT@newsreader.com>, Bill Godfrey wrote:
> > Andreas Kahari <ak+usenet@freeshell.org> wrote:
> >> A better syntax would possibly be
> >>     x <- 2
> >
> > if (x<-2) { printf("x is less than -2\n"); }
>
> It's a s bad as
>
>     if (x=0) { printf("x is 0\n"); }
>
> > I know what you mean though. I like "arrow" imagery. x <: 2 perhaps?
>
> Yes, like an arrow.  You even see it in algorithm descriptions
> in print sometimes.  Hmmm... no, "<:" lacks the arrowness.  What
> about "�"?  Maybe it's too non-ASCII?  You could also make a
> distinction between the em-dash and the shorter en-dash (for
> negation), but again, that's outside ASCII (and makes the code
> hard to read).

What about <=?

Dan.


0
Reply dartdanfm (81) 10/11/2003 3:08:06 AM

"Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote:
> On Sat, 11 Oct 2003, Corey Murtagh wrote:
> > Bill Godfrey wrote:
> > > Corey Murtagh <emonk@slingshot.co.nz.no.uce> wrote:
> > >
> > >>The way I was taught algebra,
> > >>all those years ago, 'x=y' was an assignment.
> > >
> > > That's odd. I was taught in algebra that 'x=y' was a statement of equality.
> > > x and y have always existed and they always have had an equal but
> > > unspecified value.
> >
> > Ah, memory failed me.  You're right, and I was coloring my memory with
> > programming pejudice.  I retract my earlier statement :>
>
> Well, it could be said that
>
>    f(x) = x^2
>
> is an "assignment."  Sort of.

No, it's either a statement (if f is bound) or a
definition (if f isn't).

Dan.


0
Reply dartdanfm (81) 10/11/2003 3:15:31 AM

"Bill Godfrey" <billg-usenet@bacchae.f9.co.uk.invalid> wrote:
> gswork@mailcity.com (gswork) wrote:
> > What assignment and equivalence syntax do you prefer?
>
> I prefer...
>
> > if it's pascal its a:=1 and a=1
>
> The single = should retain it's meaning from mathematics, IMO.
> I've no great feeling about what's the best assignement operator, except
> that it shouldn't be just =.

Though its meaning from mathematics has no particular
relevance in programming languages except perhaps in
declarative languages.

Dan.



0
Reply dartdanfm (81) 10/11/2003 3:16:05 AM

On Sat, 11 Oct 2003, FM wrote:
>
> "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote:
> >
> > Well, it could be said that
> >
> >    f(x) = x^2
> >
> > is an "assignment."  Sort of.
>
> No, it's either a statement (if f is bound) or a
> definition (if f isn't).

No, while I agree with the first half of your statement,
I don't agree that the above is a "definition" of anything
in the formal sense.  Now,

   f = [ R->R: f(x) = x^2 ]

(or symbols to that effect) could be a "definition" of f,
a function, in terms of its value at each input x; but
f(x) = p is a more informal description of the function,
which I prefer to think of as "to get f(x), take x^2; or,
for each x, assign x^2 to f(x)."
  Getting backer on topic, I once wrote a programming
language in which single-line functions were declared

     F(X) = X*X
     VOL(X,Y,Z) = X*Y*Z
:-)
-Arthur
0
Reply ajo (1601) 10/11/2003 7:31:21 AM

On Sat, 11 Oct 2003, Mel Wilson wrote:
>
> gswork@mailcity.com (gswork) wrote:
> >
> >btw, i quite like proper BASIC (not these 'street basics'!)
> >
> >LET a=1
> >IF a=1
> >
> >pretty clear, that, but once you omit the keyword 'LET' it loses some
> >of that clarity (IMO).
>
> Unicode 6479 and unicode 6589, or 9F50 ?

Huh? = is ASCII 61 (3Dh).  Those Unicode characters show up in my
Internet Explorer as random Chinese characters, but that's probably
due to bad setup on my part.

Does anyone have a URL or something for a table of Unicode glyphs
in image format?  Alternately, would anyone like to give a nice
dumbed-down explanation of how to get Windows to handle Unicode
properly?  (I go to sites like
http://titus.uni-frankfurt.de/indexe.htm?/unicode/unitest.htm
but I don't see every character -- lots of them are little open
boxes, and lots of them are Chinese characters, which may be
because my IE has a Chinese codepage installed, or may be because
Unicode has to have a heck of a lot of Chinese characters -- I
don't know.)

-Arthur
0
Reply ajo (1601) 10/11/2003 5:57:33 PM

"Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote:
> On Sat, 11 Oct 2003, FM wrote:
> > "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote:
> > > Well, it could be said that
> > >
> > >    f(x) = x^2
> > >
> > > is an "assignment."  Sort of.
> >
> > No, it's either a statement (if f is bound) or a
> > definition (if f isn't).
>
> No, while I agree with the first half of your statement,
> I don't agree that the above is a "definition" of anything
> in the formal sense.  Now,

Definition doesn't have to be formal.  Definition merely
attaches meaning to a name.


>    f = [ R->R: f(x) = x^2 ]

> (or symbols to that effect) could be a "definition" of f,
> a function, in terms of its value at each input x; but
> f(x) = p is a more informal description of the function,

What fuction?  If f is an unbound variable, how could you
describe it?

Very often the context is established such that R->R is
implied.  If f had not previously been bound and the
domain and range are implied by the context, I would say
it defines f.

Dan.



0
Reply dartdanfm (81) 10/11/2003 6:58:13 PM

On 10 Oct 2003 05:14:36 -0700, gswork@mailcity.com (gswork) wrote:

>What assignment and equivalence syntax do you prefer?
>
>Not that you have much choice when you use a given language:
>
>If it's C its a=1 and a==1
>if it's pascal its a:=1 and a=1
>if it's BASIC its a=1 and a=1  (huh?, but yes it is)
I preffer that language designers focus on more important aspects
of language. I preffer nonlanguage designers to still to their own
work.
0
Reply olczyk2002 (317) 10/11/2003 7:44:58 PM

>>>>> "Andreas" == Andreas Kahari <ak+usenet@freeshell.org> writes:

 Andreas> Some wanted to write "2 = x" as in "assign 2 to x".

 Andreas> A better syntax would possibly be

 Andreas> x <- 2

Hey, me too! I started to write a programming language on summer (it does not
have functions and objects, yet). On it I have

        x <- 2          as aggignment
        x = 2           as comparison
        x -> int;       as declaration of a variable (or in let declaration)


-- 
Arto V. Viitanen				                  av@cs.uta.fi
University of Tampere, Department of Computer Sciences
Tampere, Finland				      http://www.cs.uta.fi/~av/
0
Reply av111 (38) 10/13/2003 7:27:30 AM

I love C++!


0
Reply core99 (35) 10/14/2003 11:51:51 AM

"Bill Godfrey" <billg-usenet@bacchae.f9.co.uk.invalid> wrote in message
news:20031010084320.667$I1@newsreader.com...
>
> With the keyword LET, it's a bit clearer. LET x=1 tells the computer to
> change the state of play so that x=1 is a true statement.
   [snip]
> In short, my problem with the = symbol for assignment is that equality is
> merely a side effect of the act of copying. The idea assignment operator,
> for me, should be something that implies making a copy which replaces the
> old contents.
>
> What that symbol should be, I don't know.

You clearly need to learn about Cobol!!!

 - Risto -



0
Reply rlankine2 (115) 10/14/2003 11:55:02 AM

In article <Pine.LNX.4.58-035.0310111353160.5730@unix46.andrew.cmu.edu>,
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> wrote:
> 
> Does anyone have a URL or something for a table of Unicode glyphs
> in image format?  

Go to http://www.unicode.org/charts/ for PDF format.

Gorazd
-- 
Gorazd Bozic <gbx@email.si>
0
Reply gbx (14) 10/16/2003 12:07:42 PM

On Thu, 16 Oct 2003, Gorazd Bozic wrote:
>
> Arthur J. O'Dwyer wrote:
> >
> > Does anyone have a URL or something for a table of Unicode glyphs
> > in image format?
>
> Go to http://www.unicode.org/charts/ for PDF format.

Thanks!

That site agrees with my browser: 6479, 6589 and 9F50 *are*
random Chinese characters.  Mel, what were you smoking?  If
you'd said, like, Unicode 4E8C (two-horizontal-lines for "er")
or something, that would've been funny; but what did you think
those three characters were supposed to look like?

-Arthur

0
Reply ajo (1601) 10/16/2003 4:34:21 PM

27 Replies
38 Views

(page loaded in 0.391 seconds)

Similiar Articles:


















7/21/2012 2:00:52 AM


Reply: