Interesting: I changed the write_felix procedure so that it calls a 
write_string wrapper
that does a non-local goto to the end of the procedure on end of file: felix 
version
of "exceptions" .. :)

But it is called by another procedure which also writes, so I then changed 
the write_felix procedure into a generator which returns the eof flag.

The compiler then failed because I was doing a non-local goto in a function:
this isn't allowed, non-local jumps can only be done in procedures. This is 
because
Felix functions uses the machine stack, whilst procedures use linked heap 
allocated
records, and non-local goto's have to unwind the stack to find the jump target.

Unwinding is an active process which is required to NULL out return addresses
so the garbage collector can reap unused procedure frames. Unwinding the machine
stack is done differently: by throwing a C++ exception.

There is some code which attempts to unwind across function/procedure boundaries
by mixing the two techniques, but it isn't well defined or implemented: roughly 
speaking
inside a function if you have a procedure stack you could unwind it, however
the compiler generates a "micky mouse" version of flx_run to call procedures
inside functions it's basically a one-liner:  

 while(p)p=p->resume();

so such nested procedure calls can't really do non-local gotos to code OUTSIDE
the function.

Anyhow, the thing is that ordinary old generators (not ones with yields in them)
merely look like functions: actually they're procedures. They're lifted out of
expressions like

  x =  a + g i;

gives

  tmp = g i;
  x = a + tmp;

and in that form there's no reason why we can't munge g into a procedure:

  var  tmp;
  g_munged(&tmp, i);
  x = a + tmp;

and now non-local gotos inside the generator should be ok because no it's a 
procedure :)


--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to