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.On Saturday, March 14, 2015 at 9:24:40 AM UTC-4, Artyom Shalkhakov wrote:
Here is my attempt to convert some C++ template metaprogramming approaches
to ATS2, in particular, expression templates:
https://github.com/ashalkhakov/ATS-playground/blob/master/exptmp.dats
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.
As a side-effect, looks like I’m finally starting to comprehend how C++
templates work by comparing to ATS. 