Effective ATS: Word Counting

FYI:

I wrote another piece in my Effective-ATS series:

http://www.ats-lang.org/EXAMPLE/EFFECTIVATS/word-counting/

This time, I presented an example to show that one could start with
a simple running functional implementation and then turn it (with the help
of
linear types) into a memory-clean implementation that properly frees all the
dynamically allocated memory before it terminates.

Cheers!

Thanks for the example. I have two simple questions.

  1. In http://www.ats-lang.org/EXAMPLE/EFFECTIVATS/word-counting/main.html,
    it provides a template solution for stateless word counting. In ATS, we can
    use , , and etc to specify whether a function is actually a
    closure. Do these decorators apply to template declaration?

  2. In [wordcnt_vt.dats], there is something like the following

list_vt_freelin$clear

Is this the new syntax of ATS2?

Answer to 1:

No. They do not apply to implementation (initiated by the keywork
’implement’).

Answer to 2:

Yes, this syntax is new. The naming convention I use is this:

foo$bar refers to a template function used by another template function
named foo.