Topic: Is "class T::M" legal? (was: Template constraints)


Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Thu, 9 Sep 1993 10:03:35 GMT
Raw View
In article <26484@alice.att.com> ark@alice.UUCP () writes:
>In article <1993Sep1.163302.5958@utopia.druid.com> ross@utopia.druid.com (Ross Ridge) writes:
>
>> In article <26326@alice.att.com> ark@alice.UUCP () writes:
>
>> >I think this has the advantage of requiring no really new syntax...
>
>> Is this true?  I only have a copy of The C++ Programming Language,
>> 2nd ed., but as near as I can tell the grammar summary there
>> doesn't allow a "qualified-type-name" to appear after a 'class'
>> keyword in any context.
>
>That's why I said `really new' instead of `new.'
>
>Yes it might well be a grammar change, but it should be obvious to most
>what it means.

Andrew,

The original point at issue was how to provide a notation (in the language)
by which programmers could specify which members of template formal types
are themsleves types.

You suggested a notation like:

 template <class T> class TMPL
 {
  class T::M;
  ...
 };

You then claimed that this notation had "the advantage of requiring no
really new syntax".  But you failed to specify which other alternatives
this "advantage" was relative to.

Now you appear to have backed off from claiming that the notation you
proposed involved no new syntax, and you are instead claiming merely
that your proposed notation has the "advantage" of being intutively
obvious for most C++ programmers.

I would agree that the meaning of a declaration like class T::M; should
be mostly obvious to experienced C++ programmers.

However I should also mention that (likewise) the notation I have informally
suggested here previously *also* has the advantage of requiring no "really"
new syntax, and it *also* should be immediately and intutively obvious for
experienced C++ programmers.

Just in case you (or anyone else) may have forgotten what it looked like,
here again is a short example of the notation I had suggested:

 template <class T { class M; }> class TMPL
 {
  ...
 };

I actually believe that this is MORE intutively obvious than the notation
you have suggested (however I *do* admit to being a bit biased on this point).

--

-- Ronald F. Guilmette ------------------------------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------




Author: ross@utopia.druid.com (Ross Ridge)
Date: Wed, 1 Sep 1993 16:33:02 GMT
Raw View
In article <26326@alice.att.com> ark@alice.UUCP () writes:
>One way of solving this problem, which I think I and several other people
>have suggested independently, is something like this:
>
> template<class T> void template_function (T arg)
> {
>  class T::M;
>  // ...
> }
>
>I think this has the advantage of requiring no really new syntax...

Is this true?  I only have a copy of The C++ Programming Language,
2nd ed., but as near as I can tell the grammar summary there
doesn't allow a "qualified-type-name" to appear after a 'class'
keyword in any context.  Does the ARM say something different
or is there a new extention to the language that allows this?

      Ross Ridge





Author: ark@alice.att.com (Andrew Koenig)
Date: 2 Sep 93 14:08:40 GMT
Raw View
In article <1993Sep1.163302.5958@utopia.druid.com> ross@utopia.druid.com (Ross Ridge) writes:

> In article <26326@alice.att.com> ark@alice.UUCP () writes:

> >I think this has the advantage of requiring no really new syntax...

> Is this true?  I only have a copy of The C++ Programming Language,
> 2nd ed., but as near as I can tell the grammar summary there
> doesn't allow a "qualified-type-name" to appear after a 'class'
> keyword in any context.

That's why I said `really new' instead of `new.'

Yes it might well be a grammar change, but it should be obvious to most
what it means.
--
    --Andrew Koenig
      ark@research.att.com