In ATS2, linear closure-functions become much less important as programming with higher-order functions in a setting without GC can be more conveniently achieved through the use of templates.
I’m struggling to know why this conclusion. A higher order function takes a function as an argument, which is just a closure, or closure with no values in an environment. I can see that templates add flexibility in the signature of the closure as the template can take compatible parameters and be more generic, such as a generic map function.
But I don’t understand how this makes closures less important.
And the implements functions must be templates? I’ll guess yes, because template is a natural thing to expand.
Can the function around the implementations be a non template? I’ll guess no, because the inner expansion probably relies on an outer expansion.
In ATS2, linear closure-functions become much less important as
programming with higher-order functions in a setting without GC can be more
conveniently achieved through the use of templates.
I’m struggling to know why this conclusion. A higher order function takes
a function as an argument, which is just a closure, or closure with no
values in an environment. I can see that templates add flexibility in the
signature of the closure as the template can take compatible parameters and
be more generic, such as a generic map function.
But I don’t understand how this makes closures less important.
Can the function around the implementations be a non template?
Yes, it can be a non-template function.
It is very often that you want to implement a template inside a
non-template function. In this way, the template function gets to
access to the arguments of the non-template function.
Please take a look at wordcnt2.dats at the word-counting example:
Most likely, the person would immediately think about the canvas. In my
opinion, the person should
focus on drawing and forget about the canvas for a while. This is very easy
to achieve with templates.
Having too much stuff on one’s mind clutters the mind.On Sunday, January 3, 2016 at 9:58:23 PM UTC-5, Mike Jones wrote:
And the implements functions must be templates? I’ll guess yes, because
template is a natural thing to expand.
Can the function around the implementations be a non template? I’ll guess
no, because the inner expansion probably relies on an outer expansion.