Klas I wrote:
> Thanks all!
>
> I will take a look at http://tortoisesvn.tigris.org/
>
> At the moment I'm using the tarball "5 Aug 2006 Felix1.1.2 (new)".
> Maybe some changes has been made since then, because I can't get parameters
> with the fun keyword to compile.
It's possible that it got added after that release. It's comparatively
new. Felix is the fastest growing language I've ever seen, because John
never sleeps :)
> The thing I wanted to investigate was if (fun x:int) equals (x:unit->int) or
> (var x:unit->void)?
>
> If the latter is right, why the type int? Seems like Erick and John gave
> slightly different answers to Jonathan (see below).
John is almost always the person you should be listening to, and in this
case I we're both right. John just didn't give consistent examples :)
Really his example should have been this:
fun cond1(c:bool, thn:unit->int, els:unit->int) =>
if c then thn() else els() endif
;
Which is sugar for this:
fun cond2(c:bool, fun thn:int, fun els:int) =>
if c then thn else els endif
;
both functions can be called like this:
var x = 10;
var y = 0;
print$ cond1 (y == 0, {-1}, {x/y} ); endl;
print$ cond2 (y == 0, {-1}, {x/y} ); endl;
y = 2;
print$ cond1 (y == 0, {-1}, {x/y} ); endl;
print$ cond2 (y == 0, {-1}, {x/y} ); endl;
This will print out:
-1
-1
5
5
> Oh, and a last question.
> In the case of eager evaluation, are parameters evaluated from left to right
> or is the order irrelevant in Felix?
I'm not sure, but it's easy to find out:
#import <flx.flxh>
proc foo (x:int, y:int) {};
fun x1 () = { print '1'; endl; return 1; }
fun x2 () = { print '2'; endl; return 1; }
fun x3 () = { print '3'; endl; return 1; }
foo (x1(), x2(), x3());
prints out:
1
2
3
So, left to right :)
-e
-------------------------------------------------------------------------
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