Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: request for...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 15 of 15 Topic 26097 of 27670
Post > Topic >>

Re: request for member in something not a structure or union

by Keith Thompson <kst-u@[EMAIL PROTECTED] > May 9, 2008 at 02:24 PM

Bart <bc@[EMAIL PROTECTED]
> writes:
> On May 9, 7:32 pm, Keith Thompson <ks...@[EMAIL PROTECTED]
> wrote:
[...]
>> There are languages that allow the prefix to the "." "operator"
>> to be either a structure or a pointer to structure.  Usually this
>> is done by making "." polymorphic, accepting either a structure or
>> a poitner as its prefix.  (It's already polymorphic in the sense
>> that the prefix can be of any structure type.)
>>
>> IMHO the "C-like" way to do this would have been to say that the
>> prefix to the "." "operator is *always* a pointer to struct, and
>> that an expression of struct type, if and only if it's followed by
>> ".", decays to a pointer to the struct.  This would be analagous
>> to the behavior of [], which acts as if it operated on an array
>> but really only operates on a pointer that results from a conversion.
>
> So the left side side of "." is not just a struct type, but any chain
> of pointers to a struct, multi-dereferenced as necessary to get at the
> struct that "." needs? (This shows up a weakness in -> which can only
> deal with one dereference at a time.)

Hmm.  I hadn't thought about that.  Now that I do, I think the answer
is no.  Given this hypothetical feature as I've described it, if the
prefix of "." is a pointer to pointer to struct, it wouldn't decay;
the implicit conversion would be defined only for a pointer to struct.

Since the language doesn't actually have this feature, of course,
you're free to define it any way you like, but personally I don't
think the extra complication is worthwhile.  I don't think accessing a
member given a pointer-to-pointer-to-struct is nearly as common as
accessing a member given either a pointer-to-struct or a struct, and I
think the pointer-to-pointer-to-struct case is unusual enough to call
for a distinct syntax.  (The language I'm familiar with that does
allow "foo.bar" where foo is either a structure or a pointer to
structure doesn't allow it to be a pointer to pointer to structure;
when I used that language, I never missed the ability to do that.  (It
was Ada.))

[snip]

-- 
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
 




 15 Posts in Topic:
request for member in something not a structure or union
deepak <deepakpjose@[E  2008-05-08 02:12:57 
Re: request for member in something not a structure or union
pete <pfiland@[EMAIL P  2008-05-08 05:22:08 
Re: request for member in something not a structure or union
"cr88192" <c  2008-05-09 17:50:20 
Re: request for member in something not a structure or union
lawrence.jones@[EMAIL PRO  2008-05-09 14:56:54 
Re: request for member in something not a structure or union
"cr88192" <c  2008-05-10 06:59:01 
Re: request for member in something not a structure or union
Nick Keighley <nick_ke  2008-05-08 02:23:03 
Re: request for member in something not a structure or union
Richard Heathfield <rj  2008-05-08 09:27:30 
Re: request for member in something not a structure or union
viza <tom.viza@[EMAIL   2008-05-08 03:09:36 
Re: request for member in something not a structure or union
Bart <bc@[EMAIL PROTEC  2008-05-09 04:20:10 
Re: request for member in something not a structure or union
richard@[EMAIL PROTECTED]  2008-05-09 12:06:46 
Re: request for member in something not a structure or union
Keith Thompson <kst-u@  2008-05-09 11:32:10 
Re: request for member in something not a structure or union
Bart <bc@[EMAIL PROTEC  2008-05-09 12:30:34 
Re: request for member in something not a structure or union
Chris Torek <nospam@[E  2008-05-09 19:50:08 
Re: request for member in something not a structure or union
richard@[EMAIL PROTECTED]  2008-05-09 20:26:43 
Re: request for member in something not a structure or union
Keith Thompson <kst-u@  2008-05-09 14:24:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 22:16:21 CDT 2008.