Goto or coroutines close to automatons

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.

Only self tail-calls by default.

To turn mutually recursive tail-calls into jumps, you need to use the
keyword ‘fnx’ (instead of ‘fun’).

To turn all tail-calls into jumps, one usually needs to do CPS-style
compilation.On Friday, April 10, 2015 at 9:24:06 AM UTC-4, Yannick Duchêne wrote:

I should have asked this question instead: is ATS guaranteed to optimize
self tail calls only or all tail calls?

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?


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/ba812efd-49ad-40a7-a7ac-51cdfebea386%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/ba812efd-49ad-40a7-a7ac-51cdfebea386%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

The original design is this:

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.

I like this idea in general, to underline noticeable cases with specific
keywords or syntax.

The original design is this:

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?


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/5c652a42-8017-4f86-9a6e-dafa71205b87%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/5c652a42-8017-4f86-9a6e-dafa71205b87%40googlegroups.com?utm_medium=email&utm_source=footer
.

I should have asked this question instead: is ATS guaranteed to optimize
self tail calls only or all tail calls?

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?


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/11d53eca-c214-4de0-9c54-549610084edb%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/11d53eca-c214-4de0-9c54-549610084edb%40googlegroups.com?utm_medium=email&utm_source=footer
.

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?

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?