Nice!
The example typechecks. But how to run it?
It seems to work (also, there is no dispatching happening at runtime, just as it doesn't in C++). However, I found that types must be distinct for using them to represent different nodes of the syntax tree. For instance, if Tid is [assume]d to be a double, the code compiles and runs, but produces undesired results.
Also, I'm wondering if C++ references can be mimicked in ATS2? Currently, the subtrees are embedded by value, instead of by reference. I'd like to avoid GC.
It seems to work (also, there is no dispatching happening at runtime, just as it doesn't in C++). However, I found that types must be distinct for using them to represent different nodes of the syntax tree. For instance, if Tid is [assume]d to be a double, the code compiles and runs, but produces undesired results.
This is due to incorrect use of abstract types. See my code:
https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST0/exptmp.dats
Also, I'm wondering if C++ references can be mimicked in ATS2? Currently, the subtrees are embedded by value, instead of by reference. I'd like to avoid GC.
I don't quite understand the question. As it stands now, the code involves no memory allocation. When 'eval' is called, an expression value (a flat record) is passed
by reference.
See:
https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST0/exptmp_ref.dats
This one involves memory allocation. If an expression to be evaluated is known at compile-time,
then it can be constructed using static allocation.
By "static allocation", do you mean something like an approach given in Chapter 8 of Introduction to Programming in ATS, "Constructing a Statically Allocated List"?
--
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/067f50f4-2a20-43ce-af3e-a6ff00f496a1%40googlegroups.com.