Zack Weinberg <[EMAIL PROTECTED]> writes:

| On Tue, 2005-05-24 at 10:49 +0200, Gabriel Dos Reis wrote:
| > | So you don't see any value whatsoever to having (for instance) the
| > | individual constants of 'enum machine_mode' be inaccessible in most of
| > | GCC?  'cos I sure do.
| >
| > What I'm saying is that when you have a name like EXPAND_NORMAL, you
| > do not need to know the value it represents.  Just that it names a
| > constant.
| 
| We appear to be still talking about two different cases.  I am talking
| about the case where, in C++, you might declare something like
| 
| class machine_mode
| {
|   enum {
|     VOIDmode, SImode, // ...
|   } value;
| 
|  // accessors, whatever ...
| };
| 
| and then pass around 'machine_mode' objects.  Does this help?

Nothing in what I said or is proposing prevents that scenario, if you
decided to go there (despite pessimizations on x86 targets).  To pass
machine_mode around, you need it to be declared.  That same condition
holds it it were an enum.  Currently, what you want to do is not
directly possible, because functions are using numeric values
directly, therefore breaking the abstraction barrier.  What I'm
proposing is to use the *names* (instead of the values).  If and when
you convert machine_mode to a class, then you still need a way to
refer to those values, and the named constants could be silently
changed to const class machine_mode objects, that won't change
anything to the rest of the code.  That is a value of named constant
abstraction I was talking  about.  You get the abstraction for free,
with the changes I'm proposing.

-- Gaby

Reply via email to