🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3342

Re: Observations on templates

#3342
From: David Vandevoorde
Date: Fri, 09 Feb 1996 04:07
41 lines
2656 bytes
>>>>> "ER" == "Eugene Radchenko" <eugene@qsar.chem.msu.su> writes:
[...]
>>> 3) Clause [temp.arg.explicit] verses 2-3 requires that for explicit arg in
>>> member template to be present it must be qualified by 'template' keyword,
>>> e.g.
>>> X *p; p->template alloc<200>();
>>> But to use operator -> we need X class definition anyway - so we know that
>>> alloc() is a template.

>> It is needed in some situations where we do not have the X class definition
>> -- in template definitions, like with typename.

ER> And what are we supposed to do with function alloc() if we do not have the
ER> class definition and hence do not know anything about this function?

C++ compilers are not trivial things to write and it makes sense to
decompose the compilation process in well-separated ``phases''. One
such phase is lexical analysis (decomposing the source text into
tokens), another is syntactical analysis (also called parsing; classify
the tokens and their relationship) and yet another one is semantic 
analysis (``interpret the classification and relationships determined
during syntactical analysis''). 

I may be somwhat innacurate in my descriptions, but feeding back
information from semantic analysis (e.g., ``class X has no member
template alloc'') to syntactic analysis (so that it can find out that
``X::alloc is a data member, not a member function template'') makes
the process harder. The traditional example, is more along the
lines of:

	p->alloc<2>(0);

Is this meant to be equivalent to `(p->alloc < 2) > 0' or to the
invocation of a template member function? With the added syntax,
the parser knows without relying on the semantic analysis.

	Daveed
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID: <xso68dhlf6f.fsf@fork.cs.rpi.edu>
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back
References: <u9vilu8zvz.fsf@yorick.cygnus.com> <ADqNY6n4sN@qsar.chem.msu.su>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back
From: vandevod@cs.rpi.edu (David Vandevoorde)
Newsgroups: comp.std.c++
Subject: Re: Observations on templates
Date: 09 Feb 96 04:07:44 GMT
Organization: RPI Computer Science
Approved: fjh@cs.mu.oz.au
Message-ID: <xso68dhlf6f.fsf@fork.cs.rpi.edu>
References: <u9vilu8zvz.fsf@yorick.cygnus.com> <ADqNY6n4sN@qsar.chem.msu.su>
NNTP-Posting-Host: munta.cs.mu.oz.au
X-Original-Date: 08 Feb 1996 15:45:28 -0500
In-Reply-To: "Eugene Radchenko"'s message of 8 Feb 1996 17:00:57 GMT
X-Newsreader: Gnus v5.1
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMRrIouEDnX0m9pzZAQHjRgF7BcdwQBLhkwFobNwpFJ+w5HRQBQyAHTJT
 ocHe0zPXzCXChHI9PUOYmKj2lxnBdub9
 =TpIX
Originator: fjh@munta.cs.mu.OZ.AU