ATS and libguile (was Re: ATS support in Pure)

Despite all the talk of using ATS to do C-like things more safely,
which is essential, I think ATS also could find use as a cleaner way
to do Scheme-like things in C. What that partly means is using ATS as
a high-level ML-like language that is not dependent on the garbage
collector to do things like clean up after an exception.

i don’t grok that, since I thought ATS already supported that with
linear typing.

Linear types can force you to do a ‘free’ after an ‘alloc’, but I am
talking about having ‘free’, ‘close’, or practically anything else
called when a context is exited via an exception, abort-to-prompt,
etc. I believe ATS does not currently deal with that except via the
garbage collector (which would be an extremely poor way to close a
file, incidentally).

You are right. ATS does not currently deal with such a scenario.
Would you mind telling us how you handle it?On Wednesday, October 15, 2014 9:23:34 PM UTC-4, Barry Schwartz wrote:

Raoul Duke <rao...@gmail.com <javascript:>> skribis:

Despite all the talk of using ATS to do C-like things more safely,
which is essential, I think ATS also could find use as a cleaner way
to do Scheme-like things in C. What that partly means is using ATS as
a high-level ML-like language that is not dependent on the garbage
collector to do things like clean up after an exception.

i don’t grok that, since I thought ATS already supported that with
linear typing.

Linear types can force you to do a ‘free’ after an ‘alloc’, but I am
talking about having ‘free’, ‘close’, or practically anything else
called when a context is exited via an exception, abort-to-prompt,
etc. I believe ATS does not currently deal with that except via the
garbage collector (which would be an extremely poor way to close a
file, incidentally).

For instance, in C programming I often use such ‘dynamic wind’
contexts to release ‘handles’ of objects provided by libraries, in a
way that works even if Scheme extension code called by the C function
were to raise an exception. It’s surprisingly simple to set up.

Linear types still would be useful, for instance to provide proofs
that one is in the necessary context. It could be handled like I/O,
that way. Alternatively one might do it via closures, as it is done in
Scheme:

10.4 Continuations

Scheme also can do much fancier things that I have never used and do
not even want to think about, and which mix poorly with a stack-frame
language like C, though Guile supports them in C code for the sake of
completeness. (Guile does things like copy-restore the C stack.)