public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jim Kleck <jim.kleck@NetergyNet.COM>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: Nick Duffek <nsd@redhat.com>,
	Dautrevaux@microprocess.com, gdb@sources.redhat.com,
	insight@sources.redhat.com
Subject: Re: Register group proposal
Date: Tue, 27 Feb 2001 10:30:00 -0000	[thread overview]
Message-ID: <3A9BF2AF.1BDB5EF7@netergynet.com> (raw)
In-Reply-To: <3A9B0E90.D3D920EC@cygnus.com>

A consistent interface is *one* reason to have a particular interface.
However, it is not the only thing to consider, nor have the "style
advantages and disadvantages" been fully explored... at least not
in this forum.

I would note that "struct blah *" is NOT fully opaque. Its very use implies
a control structure of some sort, and it is quite different from the standard
types provided by the language. Thus it is not using the full "extensability"
of the language.

An alternative I have not seen discussed is to have "typedef void * blah"
as the public interface (then the implementation would need to cast
the object to the internal representation before operating on it).

Finally, in the "LONGEST" example, why replace "a = b + c;" with
"a = add(b, c);". My inclination would be to overload the "+" so that
no change to the users of the type are necessary.

JimK


Andrew Cagney wrote:

> Nick Duffek wrote:
> > But prohibiting typedefs ....
>
> When implementing an ``object'', I'm asking that it be done in a way
> that is consistent with other recent additions to gdb - that is
> blah.[hc] defines an opaque ``struct blah *''.  (As a style its
> advantages and disadvantages have probably now been beaten to death :-)
>
> While it does implicitly put a restriction on the use of typedefs in
> certain header files, it is not a prohibition of typedef.
>
> If someone feels that they have concerns when defining a specific
> interface then I would assume that that person will also put those
> concerns forward.  In doing this they may well demonstrate a possible
> need to implement their interface in a way that is different to the
> above.
>
> To give an example, consider LONGEST.  One day that type will need to be
> extended beyond 64 bits (long long).  When that happens, it might be
> done with something like:
>         defs.h:
>           struct longest {
>             something_goes here;
>           };
>           typedef struct longest LONGEST;
> Among the rationale would be the observation that LONGEST is a self
> contained lightweight.  You could try to implement it as a ``struct
> longest *'' but it would make memory management a nightmare while
> showing very few advantages.  Being able to perform the mechanical
> replacement:
>         a = b + c;
>   with  a = add (b, c);
> would be of much greater benefit.  (See sim/common/sim-fpu.[hc].)
>
>         Andrew

  reply	other threads:[~2001-02-27 10:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-23  2:52 Bernard Dautrevaux
2001-02-24 15:43 ` Nick Duffek
2001-02-26 18:21   ` Andrew Cagney
2001-02-27 10:30     ` Jim Kleck [this message]
2001-02-27 11:24       ` Per Bothner
2001-02-27 13:44         ` Jim Kleck
2001-02-27 15:17           ` Andrew Cagney
  -- strict thread matches above, loose matches on Subject: below --
2001-02-28  1:59 Bernard Dautrevaux
2001-02-26  5:29 Bernard Dautrevaux
2001-02-26  9:28 ` Christopher Faylor
2001-02-26 10:56   ` Andrew Cagney
2001-02-26 11:28     ` Christopher Faylor
2001-02-26 17:02       ` Andrew Cagney
2001-02-27  8:53         ` Christopher Faylor
2001-02-27  9:57           ` Andrew Cagney
2001-02-22  9:19 Michael Elizabeth Chastain
2001-02-21  3:00 Stephane Carrez
2001-02-21  7:00 ` Nick Duffek
2001-02-21  9:34 ` Andrew Cagney
2001-02-20 20:56 Nick Duffek
2001-02-21  6:44 ` Fernando Nasser
2001-02-21  7:10   ` Nick Duffek
2001-02-21  7:36     ` Fernando Nasser
2001-02-21  7:58     ` Keith Seitz
2001-02-21  8:50 ` Andrew Cagney
2001-02-21 11:43   ` Andrew Cagney
2001-02-25 15:36   ` Nick Duffek
2001-02-21 11:43 ` Andrew Cagney
2001-02-21 12:28   ` Andrew Cagney
2001-02-21 12:18 ` Andrew Cagney
2001-02-22  0:59   ` Eli Zaretskii
2001-02-22  4:29     ` Nick Duffek
2001-02-22  8:46       ` Andrew Cagney
2001-02-22  8:56         ` Keith Seitz
2001-02-22  9:20           ` Andrew Cagney
2001-02-22  5:17   ` Nick Duffek
2001-02-22  6:36     ` Fernando Nasser
2001-02-22  8:23       ` Andrew Cagney
2001-02-22  7:58     ` Andrew Cagney
2001-02-22  8:37       ` Nick Duffek
2001-02-22  9:12         ` Andrew Cagney
2001-02-22 10:15           ` Nick Duffek
2001-02-22 10:25             ` Andrew Cagney
2001-02-22 11:40               ` Eli Zaretskii
2001-02-22 11:02           ` Kevin Buettner
2001-02-22 12:08             ` Andrew Cagney
2001-02-22  8:16     ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A9BF2AF.1BDB5EF7@netergynet.com \
    --to=jim.kleck@netergynet.com \
    --cc=Dautrevaux@microprocess.com \
    --cc=ac131313@cygnus.com \
    --cc=gdb@sources.redhat.com \
    --cc=insight@sources.redhat.com \
    --cc=nsd@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).