Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Language design pointer definition

Reply
Thread Tools

Language design pointer definition

 
 
rafaelolg
Guest
Posts: n/a
 
      10-23-2005
In the definition of a pointer, why don't a keyword is used instead of
"*"?
The use of "*" does not make confusion with the * operator?
Something like:

int pointer a;
int b;
a=&b;
*a=10;

Thanks.

 
Reply With Quote
 
 
 
 
Michael Mair
Guest
Posts: n/a
 
      10-23-2005
rafaelolg wrote:
> In the definition of a pointer, why don't a keyword is used instead of
> "*"?
> The use of "*" does not make confusion with the * operator?
> Something like:
>
> int pointer a;
> int b;
> a=&b;
> *a=10;


No, * is never ambiguous in context.
If this does not satisfy you, then you need replacements for
other doubly used characters, too: "&", "#", ",", ";", ":", "(",
")", "<", ">" come to mind but maybe I could find some more.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
 
Reply With Quote
 
 
 
 
Malcolm
Guest
Posts: n/a
 
      10-23-2005

"rafaelolg" <(E-Mail Removed)> wrote
> In the definition of a pointer, why don't a keyword is used instead of
> "*"?
> The use of "*" does not make confusion with the * operator?
> Something like:
>
> int pointer a;
> int b;
> a=&b;
> *a=10;
>

One reason is that you can have multiple levels of indirection.

int *ptr;
int **2dptr;
int ***3dptr;

It's easier to see when you use the * syntax. I agree, the choice of an
asterisk was confusing, as was the use of the same symbol to declare and to
dereference a pointer.


 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      10-23-2005
"rafaelolg" <(E-Mail Removed)> writes:

> In the definition of a pointer, why don't a keyword is used instead of
> "*"?
> The use of "*" does not make confusion with the * operator?


The idea is that declaration and use look similar. That is,
declaring a pointer and dereferencing a pointer take the same
syntax. The same goes for declaring and invoking a function, and
so on.
--
Peter Seebach on C99:
"[F]or the most part, features were added, not removed. This sounds
great until you try to carry a full-sized printout of the standard
around for a day."
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time template list definition / Run-time variable type definition Pierre Yves C++ 2 01-10-2008 02:52 PM
Automagic determination of definition based on definition location. Jon Slaughter C++ 4 10-26-2005 05:00 PM
can a class definition inside another class's definition Jianli Shen C++ 1 03-13-2005 06:02 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM
help?: incomplete definition with complete definition in scope Ark C Programming 1 08-07-2004 04:21 PM



Advertisments