Memory-safe graphs without GC in ATS

95 views
Skip to first unread message

Vanessa McHale

unread,
Sep 21, 2019, 2:56:39 PM9/21/19
to ats-lan...@googlegroups.com
Hi all,

Is it possible to write memory-safe circular linked list in ATS?

Cheers,
Vanessa


signature.asc

gmhwxi

unread,
Sep 23, 2019, 1:57:24 PM9/23/19
to ats-lang-users
Certainly.

The following code is written is ATS1:


slseg(l1, l2) is a singly-linked list segment from l1 to l2. So a circular one is just
a case where l1 = l2.

If you want a doubly-linked one, please see the following;


The caveat is that writing this kind of code often requires a lot of effort that may
not be easily justified in practice.

Another approach (which I would take) is to use reference-counted nodes; it makes
the resulting code a bit slower but can drastically simplify the implementation effort.
Reply all
Reply to author
Forward
0 new messages