[m-rev.] for review; typeclass decl introduces namespace

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 1 03:27:52 AEDT 2001


On 31-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> On Wed, Oct 31, 2001 at 09:01:44PM +1100, Fergus Henderson wrote:
> > On 30-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > 
> > > Typeclass declarations now introduce a new namespace.  For example the
> > > method, f, in typeclass, tc, in module, mod, has the fully qualified
> > > name mod__tc__f instead of mod__f.  This allows typeclasses defined
> > > at the same scope to have methods with the same name.
> > ...
> > > Index: compiler/prog_io_typeclass.m
> > > @@ -625,12 +625,13 @@
> > >  		% instance declaration for, but we don't necessarily
> > >  		% know what module that is at this point, since the
> > >  		% class name hasn't been fully qualified yet.
> > > -		% So here we give the special module name ""
> > > -		% as the default, which means that there is no default.
> > > +		% So here we give the only part of the module name that
> > > +		% we do know which is the unqualified instance name.
> > >  		% (If the module qualifiers in the clauses don't match
> > >  		% the module name of the class, we will pick that up later,
> > >  		% in check_typeclass.m.)
> > > -		DefaultModuleName = unqualified(""),
> > > +		unqualify_name(InstanceName, UnqualifiedInstanceName),
> > > +		DefaultModuleName = unqualified(UnqualifiedInstanceName),
> > >  		parse_item(DefaultModuleName, VarSet, MethodTerm, Result0),
> > 
> > I don't think that is correct.
> > 
> > In particular, I think that will lead to an error for
> > 
> > 	:- module foo.
> > 	:- interface.
> > 	:- typeclass tc(T) where [
> > 		func foo__tc__bar(T) = int
> > 	].
> > 
> > since `foo__tc' won't match `tc'.
>
> The above piece of code is only for handling instance methods (not
> typeclass) methods where the code is defined inline.

Ah, I see.  In that case, the code it will incorrectly report
an error for looks like this:

	:- instance tc(t) where [
		foo__tc__bar(_) = 42
	].

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  | "... it seems to me that 15 years of
The University of Melbourne         | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list