Ok, so here's a little problem I'm struggling with:
var ch1: oschannel[event_t]; mk_field (w, 50, 60, font, black, white,
"EDITFIELD ONE", &ch1);
This looks .. er .. ugly. And its a pain because the type of ch1 has to be
declared.
Uninitialised variables looks screwy..
The reason for using a procedure: the procedure contains this:
spawn_fthread controller;
which you cannot do in a function (not even a generator).
Function like code can be converted to a procedure by changing
return value;
into
presult <- value; return;
and adding presult, a pointer to the result type, as an argument.
So we could write the code looking like a function and convert it.
Actually Felix already does this for (at least some) functions called directly,
but the functional form is required for a closure so the type is right.
That still leaves open how to use such a procedure.
We could do something like:
var x <- f a; // a type int
and have that converted to
var x: T; f a (&x);
How do we get the T? Well f would have type
a -> &T -> 0
so
T = dom (typeof (f a))
where
typedef fun dom(t:TYPE):TYPE =>
typematch t with
| ?a -> _ => a
endmatch
;
is already defined in the library. On the other hand, if the type T is given
it can participate in overload resolution.
The proposed syntax
(a) only works for a single variable
(b) only works when defining it
The second constraint means you can't do this:
x <- f a;
assuming x is already defined, because that syntax already means
to store the value returned by a function at pointer x.
Another option is to use a function to return the procedure to be run,
then we get
var ch1, cls = mkfield (..);
spawn_fthread cls;
however the semantics are subtly different: at present Felix starts executing
spawned fthreads immediately so if they return its the same as a
subroutine call. It also means that if they refer to context, the context
doesn't
also have to be a closure retained on the heap. Most fthread don't return
immediately of course ..
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language