skaller wrote: > On Mon, 2006-10-02 at 10:36 +1000, Jonathan Kelly wrote: > > >> fun jseek: file * long * int -> int = 'std::fseek($1, $2, $3)'; >> > > >> val x = jseek(fil, 0L, 2); >> // uncommenting out the following to stop previous being elided >> //print "jseek returned "; >> //print x; >> //endl; >> > > Two things to notice. First, jseek is a fun not a gen, > so the compiler assumes it is a pure function. > > Second, you're initialising an unused val from the > function .. so Felix is eliding it. Just think you'd > written: > > val x = sin y; > > and not used x .. what's the point wasting time calculating > sin y? > > You can solve this three ways: > > (a) make x a var (iable) > (b) make jseek a gen (erator) > (c) write > > ignore(jseek(fil,0L,2)) > > > Hi,
I'm not sure how to turn it into a generator. I tried gen jseek: file * long * int -> int = 'std::fseek($1, $2, $3)'; but it still ellided the call. Changing the val to var didn't help either. It's probably a silly example as I would test the value anyway, but I am more interested in how to define an external function so even if I ignored the return value, it doesn't optimise away the side-effects, which is what I'm guessing a generator is. Cheers, Jonathan. ------------------------------------------------------------------------- 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
