On Sun, 2007-03-25 at 01:42 -0700, Erick Tryzelaar wrote:
> > There's actually a 'reason' it doesn't, and the same reason indicates
> > lists should actually be defined by an anonymous union too.
> >
>
> Makes sense. Is there any way to alias the two to the same thing so that
> the type system won't complain, and have any error messages preserve the
> alias? I could imagine that could get tricky with more complicated types
> though.
Aliasing is possible: you can use a cast, for example, if you
'know' the types are layout compatible.
Aliases for anonymous union constructor names would be cool.
At present we have
macro val true = case 1 of 2;
which isn't very nice. Something like a typedef would be better.
In theory you might do
rename true = case 1 of 2;
but I don't think that will work. This is a simple case,
in a more difficult case the constructor is distinct from the
variant, eg
typedef list = 1 + int * list;
val e = case 0 of list;
val x : list = (case 1 of list) (1, e);
we'd like to name
name Cons = case 1 of list; // ****
Of course you can make a function, but that's not the same
because you can't pattern match against a function call,
only a constructor application.
**** of course you can do
macro val Cons = case 1 of list;
and you can pattern match with it too .. the problem is it's
a macro and so whilst it respects scopes, you cannot 'open'
a module containing it to make it accessible, and you can't
use qualified names with it, etc etc, like a real name.
We have that problem right now with 'print x' which is a macro
for fprint (stdout,x) ... ;(
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language