# I need a working code for stack allocated closure

**URL:** https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196
**Category:** Google Group
**Created:** [March 10, 2014, 4:28am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196 "2014-03-10T04:28:53Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 10, 2014, 4:28am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/1 "2014-03-10T04:28:53Z")

</div>

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](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)

I am getting lot of “undeclares” during compilation.

Thanks

---

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 10, 2014, 12:58pm UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/2 "2014-03-10T12:58:00Z")

</div>

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.On Mon, Mar 10, 2014 at 5:53 PM, Brandon Barker [brandon...@gmail.com](mailto:brandon...@gmail.com)wrote:

> You may need to do a clean build, described on the wiki building and  
> installing article.  
> On Mar 10, 2014 5:00 AM, “chotu s” [chot...@gmail.com](mailto:chot...@gmail.com) wrote:
> 
> > 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
> > 
> > On Mon, Mar 10, 2014 at 12:11 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > 
> > > Your version of ATS is probably not up-to-date. You can do a  
> > > git-pull and re-compile.
> > > 
> > > On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> > > 
> > > > 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
> > > > 
> > > > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > > 
> > > > > Here is the working code:
> > > > > 
> > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > > EXAMPLE/ATS-QA-LIST/stkclo.dats
> > > > > 
> > > > > Here is the Makefile for compiling the code:
> > > > > 
> > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > > EXAMPLE/ATS-QA-LIST/Makefile
> > > > > 
> > > > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > > > 
> > > > > > 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
> > > > > > 
> > > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > > > 
> > > > > > I am getting lot of “undeclares” during compilation.
> > > > > > 
> > > > > > Thanks
> > > > > 
> > > > > –  
> > > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > > > 
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%  
> > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > 
> > > > –  
> > > > 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](mailto:ats-lang-user...@googlegroups.com).  
> > > > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > 
> > –  
> > 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](mailto:ats-lang-user...@googlegroups.com).  
> > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com)[https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 10, 2014, 6:24am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/3 "2014-03-10T06:24:14Z")

</div>

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) = 256On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:

> Here is the working code:
> 
> [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats)
> 
> Here is the Makefile for compiling the code:
> 
> [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile)
> 
> On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> 
> > 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
> > 
> > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > 
> > I am getting lot of “undeclares” during compilation.
> > 
> > Thanks
> 
> –  
> 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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto: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](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .

---

<div class="post-metadata">

### Author: ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)
#### Post date: [March 10, 2014, 12:23pm UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/4 "2014-03-10T12:23:53Z")

</div>

You may need to do a clean build, described on the wiki building and  
installing article.On Mar 10, 2014 5:00 AM, “chotu s” [chot...@gmail.com](mailto:chot...@gmail.com) wrote:

> 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
> 
> On Mon, Mar 10, 2014 at 12:11 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> 
> > Your version of ATS is probably not up-to-date. You can do a  
> > git-pull and re-compile.
> > 
> > On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> > 
> > > 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
> > > 
> > > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > 
> > > > Here is the working code:
> > > > 
> > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > EXAMPLE/ATS-QA-LIST/stkclo.dats
> > > > 
> > > > Here is the Makefile for compiling the code:
> > > > 
> > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > EXAMPLE/ATS-QA-LIST/Makefile
> > > > 
> > > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > > 
> > > > > 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
> > > > > 
> > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > > 
> > > > > I am getting lot of “undeclares” during compilation.
> > > > > 
> > > > > Thanks
> > > > 
> > > > –  
> > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > > 
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%  
> > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > –  
> > > 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](mailto:ats-lang-user...@googlegroups.com).  
> > > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> 
> –  
> 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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com)[https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .

---

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 10, 2014, 9:00am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/5 "2014-03-10T09:00:28Z")

</div>

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.oOn Mon, Mar 10, 2014 at 12:11 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:

> Your version of ATS is probably not up-to-date. You can do a  
> git-pull and re-compile.
> 
> On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> 
> > 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
> > 
> > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > 
> > > Here is the working code:
> > > 
> > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > EXAMPLE/ATS-QA-LIST/stkclo.dats
> > > 
> > > Here is the Makefile for compiling the code:
> > > 
> > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > EXAMPLE/ATS-QA-LIST/Makefile
> > > 
> > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > 
> > > > 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
> > > > 
> > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > 
> > > > I am getting lot of “undeclares” during compilation.
> > > > 
> > > > Thanks
> > > 
> > > –  
> > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%  
> > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > –  
> > 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](mailto:ats-lang-user...@googlegroups.com).  
> > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [March 10, 2014, 1:04pm UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/6 "2014-03-10T13:04:52Z")

</div>

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 itOn Monday, March 10, 2014 8:58:00 AM UTC-4, chotu s wrote:

> 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.
> 
> On Mon, Mar 10, 2014 at 5:53 PM, Brandon Barker \<[brand...@gmail.com](mailto:brand...@gmail.com)\<javascript:\> wrote:
> 
> > You may need to do a clean build, described on the wiki building and  
> > installing article.  
> > On Mar 10, 2014 5:00 AM, “chotu s” \<[cho...@gmail.com](mailto:cho...@gmail.com) \<javascript:\>\> wrote:
> > 
> > > 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
> > > 
> > > On Mon, Mar 10, 2014 at 12:11 PM, gmhwxi \<[gmh...@gmail.com](mailto:gmh...@gmail.com) \<javascript:\> wrote:
> > > 
> > > > Your version of ATS is probably not up-to-date. You can do a  
> > > > git-pull and re-compile.
> > > > 
> > > > On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> > > > 
> > > > > 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
> > > > > 
> > > > > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > > > 
> > > > > > Here is the working code:
> > > > > > 
> > > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > > > EXAMPLE/ATS-QA-LIST/stkclo.dats
> > > > > > 
> > > > > > Here is the Makefile for compiling the code:
> > > > > > 
> > > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/](https://github.com/githwxi/ATS-Postiats/blob/master/doc/)  
> > > > > > EXAMPLE/ATS-QA-LIST/Makefile
> > > > > > 
> > > > > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > > > > 
> > > > > > > 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
> > > > > > > 
> > > > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > > > > 
> > > > > > > I am getting lot of “undeclares” during compilation.
> > > > > > > 
> > > > > > > Thanks
> > > > > > 
> > > > > > –  
> > > > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > > > > 
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > > 
> > > > > –  
> > > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)\<javascript:\>  
> > > > > .  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > 
> > > –  
> > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)\<javascript:\>  
> > > .  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com)[https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [March 10, 2014, 6:41am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/7 "2014-03-10T06:41:11Z")

</div>

Your version of ATS is probably not up-to-date. You can do a  
git-pull and re-compile.On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:

> 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
> 
> On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi \<[gmh...@gmail.com](mailto:gmh...@gmail.com) \<javascript:\>\>wrote:
> 
> > Here is the working code:
> > 
> > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats)
> > 
> > Here is the Makefile for compiling the code:
> > 
> > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile)
> > 
> > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > 
> > > 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
> > > 
> > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > 
> > > I am getting lot of “undeclares” during compilation.
> > > 
> > > Thanks
> > 
> > –  
> > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)\<javascript:\>  
> > .  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [March 13, 2014, 3:43pm UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/8 "2014-03-13T15:43:56Z")

</div>

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.On Thursday, March 13, 2014 12:14:48 AM UTC-4, H Zhang wrote:

> 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
> 
> On Sunday, March 9, 2014 11:41:11 PM UTC-7, gmhwxi wrote:
> 
> > Your version of ATS is probably not up-to-date. You can do a  
> > git-pull and re-compile.
> > 
> > On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> > 
> > > 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
> > > 
> > > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > 
> > > > Here is the working code:
> > > > 
> > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats)
> > > > 
> > > > Here is the Makefile for compiling the code:
> > > > 
> > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile)
> > > > 
> > > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > > 
> > > > > 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
> > > > > 
> > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > > 
> > > > > I am getting lot of “undeclares” during compilation.
> > > > > 
> > > > > Thanks
> > > > 
> > > > –  
> > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@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](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .

---

<div class="post-metadata">

### Author: ![H\_Zhang](https://avatars.discourse-cdn.com/v4/letter/h/b77776/32.png) [@H\_Zhang](https://discourse.ats-lang.org/u/H_Zhang)
#### Post date: [March 13, 2014, 4:14am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/9 "2014-03-13T04:14:48Z")

</div>

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.

HaitaoOn Sunday, March 9, 2014 11:41:11 PM UTC-7, gmhwxi wrote:

> Your version of ATS is probably not up-to-date. You can do a  
> git-pull and re-compile.
> 
> On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> 
> > 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
> > 
> > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > 
> > > Here is the working code:
> > > 
> > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats)
> > > 
> > > Here is the Makefile for compiling the code:
> > > 
> > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/Makefile)
> > > 
> > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > 
> > > > 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
> > > > 
> > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > 
> > > > I am getting lot of “undeclares” during compilation.
> > > > 
> > > > Thanks
> > > 
> > > –  
> > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@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](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .

---

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 10, 2014, 1:48pm UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/10 "2014-03-10T13:48:32Z")

</div>

Thanks , I am now able to build it from sf repository and closure code also  
works now :)On Mon, Mar 10, 2014 at 6:34 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:

> 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
> 
> On Monday, March 10, 2014 8:58:00 AM UTC-4, chotu s wrote:
> 
> > 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.
> > 
> > On Mon, Mar 10, 2014 at 5:53 PM, Brandon Barker [brand...@gmail.com](mailto:brand...@gmail.com)wrote:
> > 
> > > You may need to do a clean build, described on the wiki building and  
> > > installing article.  
> > > On Mar 10, 2014 5:00 AM, “chotu s” [cho...@gmail.com](mailto:cho...@gmail.com) wrote:
> > > 
> > > > 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
> > > > 
> > > > On Mon, Mar 10, 2014 at 12:11 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > > 
> > > > > Your version of ATS is probably not up-to-date. You can do a  
> > > > > git-pull and re-compile.
> > > > > 
> > > > > On Monday, March 10, 2014 2:24:14 AM UTC-4, chotu s wrote:
> > > > > 
> > > > > > 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
> > > > > > 
> > > > > > On Mon, Mar 10, 2014 at 11:02 AM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > > > > > 
> > > > > > > Here is the working code:
> > > > > > > 
> > > > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAM](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAM)  
> > > > > > > PLE/ATS-QA-LIST/stkclo.dats
> > > > > > > 
> > > > > > > Here is the Makefile for compiling the code:
> > > > > > > 
> > > > > > > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAM](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAM)  
> > > > > > > PLE/ATS-QA-LIST/Makefile
> > > > > > > 
> > > > > > > On Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:
> > > > > > > 
> > > > > > > > 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
> > > > > > > > 
> > > > > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> > > > > > > > 
> > > > > > > > I am getting lot of “undeclares” during compilation.
> > > > > > > > 
> > > > > > > > Thanks
> > > > > > > 
> > > > > > > –  
> > > > > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > > > > > 
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-54](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-54)  
> > > > > > > 08-4961-8e92-7c4009d88a08%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/dcf0c85e-5408-4961-8e92-7c4009d88a08%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .
> > > > > > 
> > > > > > –  
> > > > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/40c4d084-bcb3-443e-977d-94de34cee6ae%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> > > > 
> > > > –  
> > > > 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...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%  
> > > > 2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc\_wBuBnhtqa2pQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4wW2X%2BmuBcz%2Bf5DjxB%2BXcVUXzHkfnHzc_wBuBnhtqa2pQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > 
> > –  
> > 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](mailto:ats-lang-user...@googlegroups.com).  
> > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/4e394f88-72ae-4232-9e89-30f8699608f7%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/4e394f88-72ae-4232-9e89-30f8699608f7%40googlegroups.com)[https://groups.google.com/d/msgid/ats-lang-users/4e394f88-72ae-4232-9e89-30f8699608f7%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/4e394f88-72ae-4232-9e89-30f8699608f7%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [March 10, 2014, 5:32am UTC](https://discourse.ats-lang.org/t/i-need-a-working-code-for-stack-allocated-closure/196/11 "2014-03-10T05:32:39Z")

</div>

Here is the working code:

> <https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/stkclo.dats>

Here is the Makefile for compiling the code:

[https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/MakefileOn](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/MakefileOn) Monday, March 10, 2014 12:28:53 AM UTC-4, chotu s wrote:

> 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
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/ats-lang-users/wzPNLsScga4)
> 
> I am getting lot of “undeclares” during compilation.
> 
> Thanks
