And here was have it:

// define an interface with one method

interface A { 
  geta: unit -> int; 
}

// extend it with a second method

interface B extends A { 
  getb: unit  -> int; 
}

// implement a class for the first interface A

object anA (a:int) implements A = { 
  omethod fun geta()=> a; 
}

// implement a class for the extended interface B,
// by inheriting from the class 'anA' we just defined

object anB(a:int, b:int) extends anA(a) implements B = { 
  omethod fun getb()=> b;
}

// Apply the class constructor to make an object

var bb = anB(22,33);

// prove it does what we expected

println$ bb.geta(), bb.getb();
 

Ok, so: I'm thinking of tweaking the syntax more of course.

'face' instead of interface because I've been interfacing
with facebook for too long.

'obj' instead of 'object' so no one can claim Felix is actually
object oriented.

'omethod' need to be replaced. Perhaps "method" or
just "meth" would do, though the latter suggests the drug
of choice for the very poor or the very rich.

Now, I have to say I hate { .. } more and more, tempted to do

face .. endface
obj ... endobj

instead. Any suggestions to improve the look and feel most welcome.
Note the ugly "=" sign. That comes from 

        fun f(x:int) : int = { .. }

The = is required here because 

        int { .. }

is a valid expression syntactically. I like

fun f(x:int) : int 
  begin ... end

better but I'm archaic, Pascal was my first language :)

Actually, I'm not sure why it isn't needed in:

        interface A extends B  { .. }

since an interface is nothing more than a typedef of a record,
there's no reason that B should be a name, it can be any
expression (that resolves to a record type).

Maybe the syntax is a left over from the old Ocamlyacc parser,
which was only LALR(1). Dypgen might handle it better,
allow the = to be elided.

Anyhow .. as they say .. enjoy! :)

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




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to