Topic: @ in C++ (ARM page 333)
Author: thp@cs.ucr.edu (Tom Payne)
Date: 1995/04/12 Raw View
Jim Fleming (jim.fleming@bytes.com) wrote:
: In article <3mefua$f6r@info-server.bbn.com>, jkraska@bbn.com says...
: >
: >
: >> Jim Fleming <jim.fleming@bytes.com> wrote:
: >>The following is taken from, "The Annotated C++ Reference Manual",
: >>by Margaret A. Ellis and Bjarne Stroustrup...
: >>
: >>@@@@@@@@@@@@@@@@@@@@@@ page 333 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
: >>
: >>13.4.2 Binary Operators
: >>
: >>A binary operator may be declared either by a nonstatic member
: >>function (&9.3) taking one argument or by a nonmember function
: >>taking two arguments. Thus, for any operator @, x@y can be
: >>interpreted as either x.operator@(y) or operator@(x,y).
: >>
: >>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
: >>
: >>Does this mean I can use the @ operator to create objects of
: >>class Point, just like in Smalltalk?
: >>
: >>For exmple:
: >>
: >> p = x @ y;
: >>
[stuff deleted]
The ARM is using "@" as a metavariable ranging over C++-supported
binary operators. Commonly a variable designates a "fixed but
arbitrary" item in its range but is not the proper name of any of
them. Specifically, there is no operator named "@" in C++.
See Design and Evolution of C++ for Stroustrup's reasons for not
allowing the introduction of new operator symbols.
Tom Payne
Author: Joe Kraska <jkraska@bbn.com>
Date: 1995/04/11 Raw View
> Jim Fleming <jim.fleming@bytes.com> wrote:
A bunch of wierd stuff as usual.
Be that as it may, in the course of overloading operators
I have often wished that I could use @ or $ or maybe := and
so forth, but of course these things are not currently part
of the standard.
I am perfectly happy to leave the standards writing to the
standards people, but I for one can definitely see a utility
in a set of symbols that are by convention without meaning
until defined in a class library or what have you.
In fact, I think that overloading existing operators is
more likely to generate confusion than the creation of new
ones to define operations that are well-reflected by existing
operators.
So, why not include a new operator utility in the standard?
Or is this being worked on and I just don't know it?
Joe.
Author: jim.fleming@bytes.com (Jim Fleming)
Date: 1995/04/11 Raw View
In article <3mefua$f6r@info-server.bbn.com>, jkraska@bbn.com says...
>
>
>> Jim Fleming <jim.fleming@bytes.com> wrote:
>>The following is taken from, "The Annotated C++ Reference Manual",
>>by Margaret A. Ellis and Bjarne Stroustrup...
>>
>>@@@@@@@@@@@@@@@@@@@@@@ page 333 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>13.4.2 Binary Operators
>>
>>A binary operator may be declared either by a nonstatic member
>>function (&9.3) taking one argument or by a nonmember function
>>taking two arguments. Thus, for any operator @, x@y can be
>>interpreted as either x.operator@(y) or operator@(x,y).
>>
>>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>Does this mean I can use the @ operator to create objects of
>>class Point, just like in Smalltalk?
>>
>>For exmple:
>>
>> p = x @ y;
>>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
I have replaced the "bunch of wierd stuff" that Mr. Kraska
deleted and dismissed...evidently, it was not weird enough
for him to play off of it and use it to promote his views
which match mine. Maybe his views are also....wierd...???
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>
>A bunch of wierd stuff as usual.
>
>Be that as it may, in the course of overloading operators
>I have often wished that I could use @ or $ or maybe := and
>so forth, but of course these things are not currently part
>of the standard.
>
>I am perfectly happy to leave the standards writing to the
>standards people, but I for one can definitely see a utility
>in a set of symbols that are by convention without meaning
>until defined in a class library or what have you.
>
>In fact, I think that overloading existing operators is
>more likely to generate confusion than the creation of new
>ones to define operations that are well-reflected by existing
>operators.
>
>So, why not include a new operator utility in the standard?
>Or is this being worked on and I just don't know it?
>
>Joe.
>
--
Jim Fleming /|\ Unir Corporation Unir Technology, Inc.
%Techno Cat I / | \ One Naperville Plaza 184 Shuman Blvd. #100
Penn's Landing / | \ Naperville, IL 60563 Naperville, IL 60563
East End, Tortola |____|___\ 1-708-505-5801 1-800-222-UNIR(8647)
British Virgin Islands__|______ 1-708-305-3277 (FAX) 1-708-305-0600
\__/-------\__/ e-mail: jim.fleming@bytes.com
Smooth Sailing on Cruising C+@amarans ftp: 199.3.34.12 <-----stargate----+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\____to the end of the OuterNet_|
Author: Mike Ferrel <ferrel@cis.santarosa.edu>
Date: 1995/04/12 Raw View
>Firstly the section does not say that @ is a respplacement symbol.
>It says exactly what was typed above.
>
And what else would "for any" mean?
>Also. it seems curious that the example given above taken verbatim from
the
>ARM, uses x@y as if there is some reference to Points which have an
>x and y coordinate.
No, it uses @ as an arbitrary binary operator that takes arbitrary
operands x and y. x and y are also obviously replacement symbols.
--
****************************************
Mike Ferrel, Instructor
Santa Rosa Junior College Santa Rosa, CA
ferrel@cis.santarosa.edu
Author: jim.fleming@bytes.com (Jim Fleming)
Date: 1995/04/12 Raw View
In article <3mefua$f6r@info-server.bbn.com>, jkraska@bbn.com says...
>
>
>> Jim Fleming <jim.fleming@bytes.com> wrote:
>
>A bunch of wierd stuff as usual.
>
>Be that as it may, in the course of overloading operators
>I have often wished that I could use @ or $ or maybe := and
>so forth, but of course these things are not currently part
>of the standard.
>
>I am perfectly happy to leave the standards writing to the
>standards people, but I for one can definitely see a utility
>in a set of symbols that are by convention without meaning
>until defined in a class library or what have you.
>
>In fact, I think that overloading existing operators is
>more likely to generate confusion than the creation of new
>ones to define operations that are well-reflected by existing
>operators.
>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
BINGO! You hit the nail on the head...
Since many good software "engineers" have discovered that
overloading operators should be used with caution to keep
programs readable....
Why would any *good* designer design a language that restricts
you to overloading "existing" operators like +, -, *, etc.?
Yes, I could use + to concatenate two character strings and
this might make sense to people but wouldn't it be better
if "operator invention" were encouraged and NOT overloading
of a small number of existing operators?
What if mathematics had made the rule that only a few symbols
could be used and could be "overloaded" to mean different
things at different times, our text books would be a nightmare.
Instead, mathematics has invented integrals, summation symbols,
various greek alphabet conventions, etc. to encourage terse
notation and improved communication.
Via operator invention, new combinations of special characters
can be used which immediately give the reader a clue that
something different is happening and that a table of invented
operators needs to be consulted to see what is happening. If
the new operators are invented with care, then you can still
maintain the expressiveness of C while allowing software
engineers the "freedom" to create their own conventions.
For example, if <<> is used for rotate left then <>> probably
means rotate right. There is a question of whether the receiver
should always be the rotated object, but that is easily solved
by some simple semantic conventions regarding the importance
of the receiver over any argument.
For example:
i <<> 4 means rotate i left 4 positions
4 <>> i means rotate 4 right i positions
In the first case the receiver is i, in the second case the
receiver is 4. The visual attribute of the <>> symbol with
an apparent heavier right side does not reverse the convention
of assuming the receiver is on the left of the symbol. In
future versions of the system the <<> can have a special
font character or icon and the parsing still works and
the programs become that much more readable and reusable.
In any language, features have to be used in moderation and
software engineers should develop conventions for their problem
domains. Just as mathematics does not have an infinite number
of symbols, invented operators should be kept to a reasonable
number. Limiting the working set to a highly understood existing
set certainly sets a limit but also encourages software engineers
to either overuse already understood operators or to not use the
capability of the language.
The designer(s) of C++ seems to claim that having a limited
number of operators that can be overloaded is a *good* attribute
of C++. It appears to be not only an unnecessary limitation
but it also encourages poor software engineering.
This is one restriction that should be fixed in the forthcoming
C++ standard. It is NOT a syntactic nightmare as the designer(s)
claim. It has proven to be useful in other more modern OO
languages.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>So, why not include a new operator utility in the standard?
>Or is this being worked on and I just don't know it?
>
>Joe.
>
--
Jim Fleming /|\ Unir Corporation Unir Technology, Inc.
%Techno Cat I / | \ One Naperville Plaza 184 Shuman Blvd. #100
Penn's Landing / | \ Naperville, IL 60563 Naperville, IL 60563
East End, Tortola |____|___\ 1-708-505-5801 1-800-222-UNIR(8647)
British Virgin Islands__|______ 1-708-305-3277 (FAX) 1-708-305-0600
\__/-------\__/ e-mail: jim.fleming@bytes.com
Smooth Sailing on Cruising C+@amarans ftp: 199.3.34.12 <-----stargate----+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\____to the end of the OuterNet_|
Author: jaf3@ritz.cec.wustl.edu (John Andrew Fingerhut)
Date: 1995/04/10 Raw View
In article <3m73dp$mdp@News1.mcs.com>,
Jim Fleming <jim.fleming@bytes.com> wrote:
:In article <3m557m$2st@news.panix.com>, nkatz@panix.com says...
:>
:>jim.fleming@bytes.com (Jim Fleming) wrote:
:>>
:>>The following is taken from, "The Annotated C++ Reference Manual",
:>>by Margaret A. Ellis and Bjarne Stroustrup...
:>>
:>>@@@@@@@@@@@@@@@@@@@@@@ page 333 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
:>>
:>>13.4.2 Binary Operators
:>>
:>>A binary operator may be declared either by a nonstatic member
:>>function (&9.3) taking one argument or by a nonmember function
:>>taking two arguments. Thus, for any operator @, x@y can be
:>>interpreted as either x.operator@(y) or operator@(x,y).
:>>
:>>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
:>>
:>>Does this mean I can use the @ operator to create objects of
:>>class Point, just like in Smalltalk?
:>>
:>>For exmple:
:>>
:>> p = x @ y;
:>>
:
:>
:>If you re-read that section, you'll see the '@' is used as a replacement
:>symbol for '+', '-', '*', etc... The '@' symbol itself is NOT in the
:>language, and cannot be overloaded.
:>
:>NAK
:>
:
:Firstly the section does not say that @ is a respplacement symbol.
:It says exactly what was typed above.
You're correct, it doesn't say that "@" is a replacement symbol. I think
that it was written for an audience with a comprehension level higher than
that of your average third grader.
:
:Also. it seems curious that the example given above taken verbatim from the
:ARM, uses x@y as if there is some reference to Points which have an
:x and y coordinate.
Funny, I didn't see any reference to Points in that passage. I saw two
variables that are frequently used in a multitude of computer expressions
combined with a symbol that is illegal in C++ to illustrate something that
is common to all valid operators without using any of those operators
to avoid confusion.
:
:Has anyone proposed that the @ sign be added to the ANSI/ISO standard?
:Would that change the wording above? Or would it be as unclear as the
:original? Also, is the ANSI standard going to be more precise than what
:is written above?
I don't think the standard needs to be written so that a third grader
can follow it.
:
:Keep in mind this is just one small example, there are hundreds more
:which I assume will come out in the public comment period for the
:proposed C++ ANSI standard.
I personally hope they simply ignore all of your comments...that ought to
reduce the number to a manageable size.
--
Stephen Gevers
sg3235@shelob.sbc.com
Author: pjenkins@cpdsc.com (Paul Jenkins)
Date: 1995/04/10 Raw View
In article <3m73dp$mdp@News1.mcs.com> jim.fleming@bytes.com (Jim Fleming) writes:
From: jim.fleming@bytes.com (Jim Fleming)
Newsgroups: comp.lang.c++,comp.std.c++
Date: 8 Apr 1995 22:40:57 GMT
Organization: Unir Corporation
In article <3m557m$2st@news.panix.com>, nkatz@panix.com says...
>
>jim.fleming@bytes.com (Jim Fleming) wrote:
>>
>>The following is taken from, "The Annotated C++ Reference Manual",
>>by Margaret A. Ellis and Bjarne Stroustrup...
>>
>>@@@@@@@@@@@@@@@@@@@@@@ page 333 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>13.4.2 Binary Operators
>>
>>A binary operator may be declared either by a nonstatic member
>>function (&9.3) taking one argument or by a nonmember function
>>taking two arguments. Thus, for any operator @, x@y can be
>>interpreted as either x.operator@(y) or operator@(x,y).
>>
>>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>Does this mean I can use the @ operator to create objects of
>>class Point, just like in Smalltalk?
>>
>>For exmple:
>>
>> p = x @ y;
>>
>
>If you re-read that section, you'll see the '@' is used as a replacement
>symbol for '+', '-', '*', etc... The '@' symbol itself is NOT in the
>language, and cannot be overloaded.
>
>NAK
>
Firstly the section does not say that @ is a respplacement symbol.
It says exactly what was typed above.
This is simple substitution phrasing, much like in mathematics. It says
"for any operator @" where the 'any' should give you a clue.
Also. it seems curious that the example given above taken verbatim from the
ARM, uses x@y as if there is some reference to Points which have an
x and y coordinate.
No, the above statement has nothing to do with Points -or- x and y
coordinates. If you read the above correctly x and y can be any class
type and the interpretation is as shown. I have no problem with the
above statement, it is very concise and easy to understand.
Has anyone proposed that the @ sign be added to the ANSI/ISO standard?
Would that change the wording above? Or would it be as unclear as the
original? Also, is the ANSI standard going to be more precise than what
is written above?
How would that @ sign be added? I can already type it anytime I want.
Keep in mind this is just one small example, there are hundreds more
which I assume will come out in the public comment period for the
proposed C++ ANSI standard.
And I hope the comments you make on those hundred have a little more
thought put into them then the above statements.
Paul
--
Jim Fleming /|\ Unir Corporation Unir Technology, Inc.
%Techno Cat I / | \ One Naperville Plaza 184 Shuman Blvd. #100
Penn's Landing / | \ Naperville, IL 60563 Naperville, IL 60563
East End, Tortola |____|___\ 1-708-505-5801 1-800-222-UNIR(8647)
British Virgin Islands__|______ 1-708-305-3277 (FAX) 1-708-305-0600
\__/-------\__/ e-mail: jim.fleming@bytes.com
Smooth Sailing on Cruising C+@amarans ftp: 199.3.34.12 <-----stargate----+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\____to the end of the OuterNet_|
--
Paul Jenkins
DSC Communications Corp.
Plano, TX
(214) 519-7659
Author: davis@ilog.fr (Harley Davis)
Date: 1995/04/11 Raw View
In article <3mbvqt$h5q@ritz.cec.wustl.edu> jaf3@ritz.cec.wustl.edu (John Andrew Fingerhut) writes:
Jim Fleming <jim.fleming@bytes.com> wrote:
:Keep in mind this is just one small example, there are hundreds more
:which I assume will come out in the public comment period for the
:proposed C++ ANSI standard.
I personally hope they simply ignore all of your comments...that ought to
reduce the number to a manageable size.
I don't think they are allowed to ignore public comments; all have to
be answered, if only to justify why they are being ignored. Then
there has to be another public review. I think a serious, hardworking
crackpot could cause havoc with the ANSI/ISO standardization process.
-- Harley Davis
--
------------------------------------------------------------------------------
Harley Davis net: davis@ilog.fr
ILOG S.A. tel: +33 1 46 63 66 66
2 Avenue Galli ni, BP 85 fax: +33 1 46 63 15 82
94253 Gentilly Cedex, France url: http://www.ilog.com/
Ilog Talk information: info@ilog.com
Author: jim.fleming@bytes.com (Jim Fleming)
Date: 1995/04/08 Raw View
In article <3m557m$2st@news.panix.com>, nkatz@panix.com says...
>
>jim.fleming@bytes.com (Jim Fleming) wrote:
>>
>>The following is taken from, "The Annotated C++ Reference Manual",
>>by Margaret A. Ellis and Bjarne Stroustrup...
>>
>>@@@@@@@@@@@@@@@@@@@@@@ page 333 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>13.4.2 Binary Operators
>>
>>A binary operator may be declared either by a nonstatic member
>>function (&9.3) taking one argument or by a nonmember function
>>taking two arguments. Thus, for any operator @, x@y can be
>>interpreted as either x.operator@(y) or operator@(x,y).
>>
>>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
>>Does this mean I can use the @ operator to create objects of
>>class Point, just like in Smalltalk?
>>
>>For exmple:
>>
>> p = x @ y;
>>
>
>If you re-read that section, you'll see the '@' is used as a replacement
>symbol for '+', '-', '*', etc... The '@' symbol itself is NOT in the
>language, and cannot be overloaded.
>
>NAK
>
Firstly the section does not say that @ is a respplacement symbol.
It says exactly what was typed above.
Also. it seems curious that the example given above taken verbatim from the
ARM, uses x@y as if there is some reference to Points which have an
x and y coordinate.
Has anyone proposed that the @ sign be added to the ANSI/ISO standard?
Would that change the wording above? Or would it be as unclear as the
original? Also, is the ANSI standard going to be more precise than what
is written above?
Keep in mind this is just one small example, there are hundreds more
which I assume will come out in the public comment period for the
proposed C++ ANSI standard.
--
Jim Fleming /|\ Unir Corporation Unir Technology, Inc.
%Techno Cat I / | \ One Naperville Plaza 184 Shuman Blvd. #100
Penn's Landing / | \ Naperville, IL 60563 Naperville, IL 60563
East End, Tortola |____|___\ 1-708-505-5801 1-800-222-UNIR(8647)
British Virgin Islands__|______ 1-708-305-3277 (FAX) 1-708-305-0600
\__/-------\__/ e-mail: jim.fleming@bytes.com
Smooth Sailing on Cruising C+@amarans ftp: 199.3.34.12 <-----stargate----+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\____to the end of the OuterNet_|