non-local exits are icky Tom Lord (23 Dec 2003 23:07 UTC)
Re: non-local exits are icky Michael Sperber (26 Dec 2003 15:41 UTC)
Re: non-local exits are icky Tom Lord (26 Dec 2003 18:14 UTC)
Re: non-local exits are icky Michael Sperber (26 Dec 2003 18:30 UTC)
Re: non-local exits are icky Tom Lord (26 Dec 2003 19:19 UTC)
Re: non-local exits are icky Michael Sperber (27 Dec 2003 16:16 UTC)
Re: non-local exits are icky Tom Lord (27 Dec 2003 18:38 UTC)
Re: non-local exits are icky Michael Sperber (27 Dec 2003 18:43 UTC)

Re: non-local exits are icky Michael Sperber 27 Dec 2003 16:16 UTC

>>>>> "Tom" == Tom Lord <xxxxxx@emf.net> writes:

>> From: Michael Sperber <xxxxxx@informatik.uni-tuebingen.de>

Tom> Since the mechanism of these non-local exits is not
Tom> specified and can not be modified by C code, the FFI
Tom> contains no provision for them to perform unwind protection
Tom> --- that's a serious omission.

>> But SCHEME_CALL takes you back to Scheme, where you can use
>> DYNAMIC-WIND.

>> I think I misunderstand your point.

Tom> A sketch that illustrates the issue:

Tom>   my_fn ()
Tom>   {
Tom>     int fd;

Tom>     fd = open ("somefile", O_RDONLY, 0);

Tom>     SCHEME_CALL ( [...] );

Tom>     close (fd);
Tom>   }

Of course, you're not supposed to do this.  You're supposed to do
(very roughly):

scheme_value my_open()
{
    return SCHEME_ENTER_LONG((long) open ("somefile", O_RDONLY, 0));
}

...

scheme_value my_close(scheme_value fd)
{
    close((int) SCHEME_EXTRACT_LONG(fd));
}

... and handle the non-local control flow from Scheme.  C just isn't
powerful enough to play these games gracefully.

--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla