I need a working code for stack allocated closure

60 views
Skip to first unread message

chotu s

unread,
Mar 10, 2014, 12:28:53 AM3/10/14
to ats-lan...@googlegroups.com
Hello ,

If possible I would like to see a full working example code for stack allocated closures  , I am unable to compile example given here

https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4

I am getting lot of "undeclares"  during compilation.

Thanks

gmhwxi

unread,
Mar 10, 2014, 1:32:39 AM3/10/14
to ats-lan...@googlegroups.com

chotu s

unread,
Mar 10, 2014, 2:24:14 AM3/10/14
to gmhwxi, ats-lan...@googlegroups.com
I am still unable to compile it properly .

Here is the code I am trying :

#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"


implement main0 () = {

  var f = lam@ () : void  => {}

}


Assume that above is in c1.dats file .

I build like this :

 patscc -DATS_MEMALLOC_LIBC -o c1 c1.dats


I get following output :


exec(patsopt --output c1_dats.c --dynamic c1.dats)
Hello from ATS2(ATS/Postiats)!
Loading [fixity.ats] starts!
Loading [fixity.ats] finishes!
Loading [basics_pre.sats] starts!
Loading [basics_pre.sats] finishes!
Loading [basics_sta.sats] starts!
Loading [basics_sta.sats] finishes!
Loading [basics_dyn.sats] starts!
Loading [basics_dyn.sats] finishes!
Loading [basics_gen.sats] starts!
Loading [basics_gen.sats] finishes!
Loading [stream.dats] starts!
Loading [stream.dats] finishes!
Loading [stream_vt.dats] starts!
Loading [stream_vt.dats] finishes!
The 1st translation (fixity) of [c1.dats] is successfully completed!
The 2nd translation (binding) of [c1.dats] is successfully completed!
The 3rd translation (type-checking) of [c1.dats] is successfully completed!
The 4th translation (type/proof-erasing) of [c1.dats] is successfully completed!
exec(patsopt --output c1_dats.c --dynamic c1.dats) = 0
exec(gcc -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64  -DATS_MEMALLOC_LIBC -o c1 c1_dats.c)
c1_dats.c: In function ‘mainats_void_0’:
c1_dats.c:259:1: error: ‘tmpref1’ undeclared (first use in this function)
c1_dats.c:259:1: note: each undeclared identifier is reported only once for each function it appears in
c1_dats.c:281:1: error: ‘__patsfun_1$closurerize’ undeclared (first use in this function)
exec(gcc -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64  -DATS_MEMALLOC_LIBC -o c1 c1_dats.c) = 256










--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com.

gmhwxi

unread,
Mar 10, 2014, 2:41:11 AM3/10/14
to ats-lan...@googlegroups.com, gmhwxi
Your version of ATS is probably not up-to-date. You can do a
git-pull and re-compile.

chotu s

unread,
Mar 10, 2014, 5:00:28 AM3/10/14
to gmhwxi, ats-lan...@googlegroups.com
Is this feature in released version  0.0.6(I have this installed) or it is only in development version.

I cloned the github repo , but having difficulty in building it

Getting lots of "undefined reference to ..." and "invalid symbol index" crt1.o


Brandon Barker

unread,
Mar 10, 2014, 8:23:53 AM3/10/14
to chotu s, ats-lan...@googlegroups.com, Hongwei Xi

You may need to do a clean build, described on the wiki building and installing article.

chotu s

unread,
Mar 10, 2014, 8:58:00 AM3/10/14
to Brandon Barker, ats-lan...@googlegroups.com, Hongwei Xi
Clean build also does not work.
It get stuck when it tries to build patscc and it has already built patsopt.

But it is ok , not a show stopper since I am not writing any serious code , I will use it in next release.

gmhwxi

unread,
Mar 10, 2014, 9:04:52 AM3/10/14
to ats-lan...@googlegroups.com, Brandon Barker, Hongwei Xi
It is straightforward to build the up-to-date version:

git clone git://git.code.sf.net/p/ats2-lang/code ATS2
cd ATS2
./configure
make all
sudo make install // only if you need it

chotu s

unread,
Mar 10, 2014, 9:48:32 AM3/10/14
to gmhwxi, ats-lan...@googlegroups.com, Brandon Barker
Thanks , I am now able to build it from sf repository and closure code also works now :)


H Zhang

unread,
Mar 13, 2014, 12:14:48 AM3/13/14
to ats-lan...@googlegroups.com, gmhwxi
Is ATS2 compiler (files in src/CBOOT) still dependent on ATS/Anairiats? If one wants to change any of the src/*.*ats file and rebuild one needs to have ATS1 installed? It would be nice to make the main data structures and main translation functions available to the C interface (with unscrambled names). That way one can link with a dynamic language REPL and examine the data structures on the fly.

Haitao

gmhwxi

unread,
Mar 13, 2014, 11:43:56 AM3/13/14
to ats-lan...@googlegroups.com, gmhwxi
Yes, you need ATS1 to generate the C files in src/CBOOT.

For developing ATS2, I write code in ATS1. However, ATS1 and ATS2 are
syntactically similar. The template system in ATS1 is quite limited when compared to that of ATS2.

We do have a plan to document the syntax trees of the C code generated from ATS source.
Reply all
Reply to author
Forward
0 new messages