This should work but doesn't:

class X[T] {
  fun f(x:T)=>1;
}

class Y {
  inherit[U] X[U * U];
}

open Y;
println$ f (2,3);


The corresponding open DOES work. I.e. 

class Y {
  open[U] X[U * U];
  println$ f (2,3);
}

works fine. The only difference to inherit is that the entries
go into the public symbol table as well as the private one,
so this should be a no-brainer.

I know why it doesn't work (the U in inherit[U] is just ignored).
However the code for inheriting stuff is quite different,
because inherits propagate, and when I try to fix it I get an
infinite recursion.

In general, Felix has a problem because it's lookup rules are
so powerful compared to other languages:

* lookup is setwise, not sequential
* opening scopes for lookup allows simultaneous partial specialisation

So there's an intrinsic recursion here: to open a scope for lookup,
you actually have to bind the specialisation too. In what scope
do you bind it? You can say the scope containing the open or
inherit statement .. you'd be right. The problem is that scope ..
is also populated by symbols from the partial specialisation
you're in the process of doing!

It is VERY hard to manage this kind of recursion. There are no simple
solutions. Felix has a thing called a "bare environment" which is one
which doesn't have any opens in it, but most of the standard library
is actually made available that way. There's also full environment
*up to but excluding the current level*, and including the raw
stuff of the current level .. but not any opened/inherited stuff.

there was even a really hairy one that tried to bind everything
in the current context, and if it failed dropped some of the context
and retried.

But this is still a trick, because recursion in Felix isn't just across
sibling module boundaries, it can be anywhere.

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to