Thanks the example helped me to see how a program can be structured. So
free_* are called manually?
Does this (in eval_exp) cause memory to be freed, or do these merely
consume the proof:
prval () = fpf (pf)
(pf | fpf) seems to ultimately come from UN.ptr_vtake, which is in turn:
//
// HX: only if you know what you are doing …
//
symintr ptr_vtake
castfn ptr0_vtake
{a:vt0p} (ptr):<> [l:addr] (a@l, a@l -<lin,prf> void | ptr l)
overload ptr_vtake with ptr0_vtake of 0
castfn ptr1_vtake
{a:vt0p}{l:addr} (ptr l):<> (a@l, a@l -<lin,prf> void | ptr l)
overload ptr_vtake with ptr1_vtake of 10
HaitaoOn Saturday, March 1, 2014 8:55:15 AM UTC-8, gmhwxi wrote:
In general, there are two styles.
If the abstract syntax tree is a genuine tree (that is, no sharing of
nodes), you can
can form a dataviewtype for such a tree. There are plenty examples like
this ATSLIB
(for instance, linmap_avltree).
If the abstract syntax tree needs to support sharing of codes, then you
probably want
to use reference-counted nodes. I did an example to illustrate this idea:
https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/calc_refcount.dats
Abstract syntax trees are often not given linear types because there is
rarely a genuine need for
doing so. However, it make sense to use linear types for internally
generated trees. What is really
great about ATS is that you can start with non-linear types to get an
functioning implementation and
then rely on typechecking to guide you when you want to replace non-linear
types with linear types.
Unless you are already quite familiar with ATS, I would not suggest that
you start with linear datatypes.
On Saturday, March 1, 2014 12:38:35 AM UTC-5, H Zhang wrote:
To narrow the question even further, take the interface defined in
src/pats_hidynexp.sats (or a similar file) as an example. If one were to
use linear types what would the interface look like? Would the
implementation and instantiation of the types involved significantly change?
Haitao
On Thursday, February 27, 2014 4:27:19 PM UTC-8, H Zhang wrote:
This is a continuation of a previous thread:
Redirecting to Google Groups The
thread title there is no longer relevant so I decided to switch to a new
thread.
Hongwei,
The reason I asked so many questions is that I have been having trouble
envisioning how a large program in which ATS may be a part of should be
structured. Maybe it is better to ask a more concrete question relevant to
ATS. Suppose we want to modularize ATS compiler infrastructure. Suppose
firstly we want to create a library that anyone can use to produce ATS
abstract syntax tree (AST of ATS Because this will be a library that may
be used in long running applications, say a future REPL facility for ATS,
so a) GC dependency is not allowed (so anyone can use the library) and b)
leaking memory is not allowed (so long running applications can use it).
How would you go about structure the code base?
Haitao