Note to self:

A class can acquire functionality by the following trick:


class List { 
...
  //$ Construe a list as a set, imbuing it with a membership
  //$ test, provided the element type has an equality operator.
  instance[T with Eq[T]] Set[list[T],T] {
    fun \in (x:T, a:list[T]) => mem[T,T] eq of (T * T) a x;
  }

  inherit [T with Eq[T]] Set[list[T],T];
...

What this does is define the "in" operator for lists
as an instance of the "in" virtual function in class Set.
So you can write:

        x in X

as a predicate.

So we get all the methods of Set available that are based
on "in". However these methods are in Set not in List.
To fix that, we inherit the specialisation of the class we
just instantiated.

Now the "in" method and all methods derived from it in Set
are available in BOTH Set and in List: A list "ISA" set.

Now the problem: this is the same problem all OO languages have:
what methods are available in Set? You have to go look it up.
This really sucks.

I cannot fix this problem as such, its a consequences of
partitioning and joining and subclassing and all that stuff.

Rather, in the "instance" and/or "inherit" directives, the
class should be hyperlinked. This requires a dictionary
mapping the class name to a URI. There is already a tool
doing this to present the library index by identifier,
I just need to munge it a bit and get the webserver to either
use it, or at least use it to create a "tags" dictionary it can
use.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to