On Fri, 2007-01-12 at 13:28 -0800, Erick Tryzelaar wrote:

> Could we do:
> 
> namespace foo::bar[t]::baz[u where u = t + 1] { ...
> 
> ?

This should work now, a bit painful, but almost everything
is converted. Known exceptions:

* parallel initialisations

var X::a,Y::b,Z::c = 1,2,3; // and the val case

doesn't work. This is  a parallel assignment, it probably doesn't
make sense to split it up into three separately sequenced assignments.
This makes sense:

var X::(a,b,c) = 1,2,3;

but isn't implemented. This include 'val' and 'def'.

* class members

Doesn't make sense unless we define a kind of 'open' class:
classes, like modules, are conceptually closed .. after all
that's "encapsulation" .. :)

* procedure assignment

var &x : int <- read 1;

This is a hack. No we can't used generators here, "read" has to
be a procedure because it's a fibre. This needs to be cleaned up.

//////////////////////////////////////////////////////////////////////////
Red Herring: it is tempting to convert Felix functions to procedures
universally to get rid of this problem: we could use CPS transform 
to do that. The issues is that most functions are *already* converted
to procedural code by the simple act of inlining them. I think CPS
would actually make inlining harder, because 'the rest of the function'
is passed as an argument .. that is, a closure .. and closure
elimination is tricky. But I don't know.

In a PURE version of Felix .. one which doesn't pander so much to 
C/C++ object and execution model, we'd probably do this. In such
a system there's no problem calling C functions from the system:
the problem is it doesn't support C calling Felix. This is already
the case for fibres however, since they're continuations.

The only way to implement that properly would require 
hardware/C stack swapping. This can be done now .. entirely
portably .. using pthreads.
////////////////////////////////////////////////////////////////////////

Anyhow the bottom line is you can now write code like:

fun X::f()=>x;
var X::X = 1;
namespace X { print$ f(); endl; }

and expect it to work. Note the cute trick:

var Seq1::x = 1;
var Seq2::x = 1;
var Seq1::y = x;
var Seq2::y = y;

BE WARNED! This means:

namespace Seq1 { x = 1; y = x; }
namespace Seq2 { x = 1; y = x; }

in particular ALL THE CODE in the statement is executed in
the scope of the namespace. This is the SAME as C++ class member
definitions:

T X::f(x:U){ .. }

except that C++ has a wart: the 'T' is elaborated in the current scope,
whereas the U is elaborated in the scope X.

However it is surprising you don't have to write:

var Seq2::y = Seq2::x;

.. well it surprised me anyhow .. :)


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to