A small project in ATS2 (announcement)

Hi,

I managed to implement a simple calculator in ATS2.

https://github.com/githwxi/ATS-Postiats/tree/master/doc/PROJECT/SMALL/calculator

I would like to use this example to demonstrate a typical way of doing a
small project in ATS2.

I first create a file ‘calculator.sats’ and declare some abstract types in
it. An abstract type is
a bit like an abstract class in OOP with no support for inheritance. I then
declare some functions
manipulating values of these abstract types. For each abstract type XXX, I
create a file calculator_XXX.dats
and put into the file the code that implements functions related to XXX. I
put the main function in
calculator.dats. Note that various dynload-declarations are also given in
calculator.dats.
Also, I put some print functions in calculator_print.dats, which can be
used for debugging.

As GC is needed for this example, the flag -DATS_MEMALLOC_GCBDW is passed
to gcc to support
the use of libgc (Bohem GC) for handling memory allocation/deallocation.
See the Makefile for more details.

Hope that you will agree with me that doing a project in ATS2 is mostly
straightforward.

Feel free to ask questions here if you have any.

Cheers!