On Tue, 2007-09-18 at 22:45 -0700, Erick Tryzelaar wrote:
> On 9/18/07, skaller <[EMAIL PROTECTED]> wrote:
> > Well, they're not interchangeable since (1,2) doesn't specify
> > any labels.
>
> Thats okay. Are you planning on implementing it?
>
> > in any case this now works:
>
> Cool! Oh, do you think we could declare types this way too? Maybe:
>
> typedef foo = (a:int, b:int);
>
> Or to have it similar to tuples:
>
> typedef foo = a:int * b:int;
Yes, possibly. However at present I'm wrestling with a different
problem: making this:
/////////////////////////////////
struct X { aa:int; bb:int; };
val k = X (1,2);
println q"aa=$(k.aa), bb=$(k.bb)";
val j = X (aa=11,bb=22);
println q"aa=$(j.aa), bb=$(j.bb)";
///////////////////////////
work. Now, in theory X can be used as a function:
X: int * int -> X
and this (should!) work in applications:
X (1,2)
and does in the example above. However, you can't use X as a function
value:
//////////////////////////////////////////
struct X { aa:int; bb:int; };
val k = X (1,2);
println q"aa=$(k.aa), bb=$(k.bb)";
var f = X of (int * int);
var z = f (1,2);
println q"aa=$(z.aa), bb=$(z.bb)";
/////////////////////////////////////
SYSTEM FAILURE
[gen_expr: closure] Can't wrap primitive proc, fun, or struct 'X' yet
//////////////////////////////////////
Woops .. :)
Of course this doesn't work in Ocaml either, and the workaround is
the same: eta-expansion:
fun f (x:int, y:int)=> X (x,y);
is a 'manual' wrapper.
OK, so the reason for explaining all this is that X a is FIRST
bound like
apply (closure X, a)
and later this is fixed up to be
apply_ctor (X,a)
where X is known to be a struct constructor, i.e. X here is an
integer symbol number, NOT a general expression.
The problem is, a here is a tuple, not a record. I can handle that.
But later, if I actually wrap 'X as a function' with automatic
eta-expansion -- you will note the diagnostic LIES about primitives,
they ARE automatically wrapped -- then there is no way to wrap
'X as function taking some kind of record argument' without knowing
which argument type it is.
In other words I cheated by the assumption the argument of a struct
constructor can only be a tuple of its components :)
Anyhow .. this CAN be done.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language