ATS/C programming: a book

88 views
Skip to first unread message

Artyom Shalkhakov

unread,
Apr 6, 2018, 2:38:44 AM4/6/18
to ats-lang-users
Hi all,

I wrote this intro here:

https://ashalkhakov.gitbooks.io/ats-c-programming/content/

The idea is to provide a better learning experience for C programmers (and maybe C++ programmers).

The plan is to cover these things:

1. handling command line arguments (the argv type in ATS)
2. working with strings (strbuf, etc.-- why so many types for strings in ATS)
3. working with global mutable state (static memory allocation, precisely what one does in C)
4. separate modules (sats/dats distinction, focussing on what the C programmer does instead)
5. working with arrays (also why strbuf is not simply an array, although it might be backed by one)
6. working with macros in C and ATS (also why macros are different in ATS), with some typical examples (constants, conditional compilation, etc.)
7. file or console I/O
8. printing values to STDOUT (and why ATS doesn't provide the printf function)
9. working with mutable pointer-based data structures (lists, trees, etc.)
10. doubly-linked data structures/various difficult-to-tackle aliasing scenarios
11. how to handle opt with by-ref parameters / what that means for C programmers (pointer-to-pointer etc.)
12. mutable state and branching/cases
13. loops/recursive functions (why use loops instead of functions and vice versa)

I just took the K&R's book about C and re-written their examples in ATS. It's really unfinished. Thoughts?

gmhwxi

unread,
Apr 7, 2018, 9:46:13 AM4/7/18
to ats-lang-users
Hi Artyom,

I am so pleased to see that you have finally got started writing the book :)

Definitely looking forward to more content.

In the following directory, I stored some examples showing a way in ATS
to make use the STL of C++:

https://github.com/githwxi/ATS-Postiats/tree/master/contrib/ats2cpp

Once you decide to move into C++, these examples could be useful to your
writing.

Cheers!
Reply all
Reply to author
Forward
0 new messages