As far I know, and according to this newsgroup, ATS2 does not have the goto
statement I though about to implement coroutines. The coroutines I have in
mind do not invoke recursive functions (although they invoke functions),
only iteration (terminal recursion, not the same as general recursion), and
a discrete value would be enough to determine the point where to resume
(that’s why I though about goto), beside a reference to the coroutines
data, which would be a linear type.
Out of curiosity, as I believe coroutines may help me in some ways, is
there a way to help supporting coroutine with no general recursion? The
latter point implies obviously bounded an even fixed allocation, which is
important, as it makes a coroutine implementation easier. Finally, a kind
of coroutine which is very close to an automaton (with some differences).
I though about automated rewriting, but what I had in mind, involves goto.
For now, this question is just a prospective question, and I though it may
interest future ATS2 users too.
I don’t have much experience with coroutines … so i’m not sure if the
example posted on the google group a couple of years ago was any use (see
“leak my coroutine”). In ATS there is a way to have mutual tail call
optimization http://www.cs.bu.edu/~hwxi/ATS/DOCUMENT/TUTORIALATS/HTML/c244.htmlOn Fri, Apr 10, 2015 at 9:24 AM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:
I should have asked this question instead: is ATS guaranteed to optimize
self tail calls only or all tail calls?
Using ‘fnx’ means to require all the recursive calls in the body of the
defined
function to be tail-calls. It is yet to be fully enforced.On Fri, Apr 10, 2015 at 11:33 AM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:
Le vendredi 10 avril 2015 16:18:06 UTC+2, gmhwxi a écrit :
Only self tail-calls by default.
To turn mutually recursive tail-calls into jumps, you need to use the
keyword ‘fnx’ (instead of ‘fun’).
(I forgot a question) Why is this not the default? Is there a
technical/stability reason?
If something is written in this style, how well do ATS support it?
There is currently no support for it in ATS.
If you are interested, you could think of a way to recompile the C code
generated from ATS source.On Fri, Apr 10, 2015 at 11:31 AM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:
Le vendredi 10 avril 2015 16:18:06 UTC+2, gmhwxi a écrit :
Only self tail-calls by default.
To turn mutually recursive tail-calls into jumps, you need to use the
keyword ‘fnx’ (instead of ‘fun’).
I did not knew fnx, thanks for the notice.
To turn all tail-calls into jumps, one usually needs to do CPS-style
compilation.
If something is written in this style, how well do ATS support it?