Some examples that might be helpful

72 views
Skip to first unread message

chotu s

unread,
Mar 4, 2014, 10:57:55 AM3/4/14
to ats-lan...@googlegroups.com
I have written some examples on array and classdec that might be helpful to some user of ATS. Most of these examples are similar to examples in "doc" of ATS and some directly taken from sources in ATS contrib and lib.

https://bitbucket.org/chotu/ats_code_collect_public/src/


Some of array examples consists of converting a array allocated on a stack to arrayptr , arrayview to arrayptr and arrayptr to arrayview.

A classdec example consist of simple single standalone application of gtk and does not use gtk from contrib.


Just a side note these might not be idiomatic of doing thing in ATS and can't even say they are correct.

gmhwxi

unread,
Mar 4, 2014, 9:49:26 PM3/4/14
to ats-lan...@googlegroups.com

Thanks for sharing it!

I can see that you are getting more and more comfortable with ATS :)

If more and more people are willing to contribute, then it may no longer be too far-stretched to
say that ATS will be able to make a visible positive impact on the qualify of software in the future.
In particular, the quality of systems software!

gmhwxi

unread,
Mar 4, 2014, 9:50:35 PM3/4/14
to ats-lan...@googlegroups.com
I forgot the mention that I added objectify/unobjectify into prelude/arrayptr.
Give them a try if you have time.

H Zhang

unread,
Mar 5, 2014, 1:08:05 AM3/5/14
to ats-lan...@googlegroups.com
If systems software is the target shouldn't we try harder to remove dependence on GC? Or is it your view that non-linear types do not add much value in ATS? What about higher order functions and closures? If stack allocation is the answer how does one return a closure that is stack allocated (I assume functions are first class objects in ATS but I may be mistaken)? Or is GC dependence acceptable for systems software? Even if that were the case it is still hard to create portable libraries (which I think is where ATS could really shine, at least in the beginning) if there is a dependence on access to runtime GC.

Haitao

Brandon Barker

unread,
Mar 5, 2014, 1:11:28 AM3/5/14
to ats-lan...@googlegroups.com
My impression is use of GC is often done while prototyping something.

For stack allocated closures see this thread:

Brandon Barker

unread,
Mar 5, 2014, 1:14:19 AM3/5/14
to ats-lan...@googlegroups.com
I'm pretty sure functions are first class objects, but not function templates.

Brandon Barker
brandon...@gmail.com


--
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/e373105c-2177-4c44-801d-9a9e5d916f75%40googlegroups.com.

Message has been deleted

gmhwxi

unread,
Mar 5, 2014, 9:55:31 AM3/5/14
to ats-lan...@googlegroups.com
One thing that sets ATS apart from other programming languages
is the support for gradually transitioning an implementation that depends on
GC into one that does not. This kind of transitioning can be guided by
typechecking.

There are several ways to use higher-order functions in ATS without the
need for GC:

1) Using templates.
2) Using stack-allocated closures.
3) Using linear closures, which are heap-allocated and can be safely freed.

Note that (1) and (2) do not even rely on malloc/free. So in ATS, you can
use higher-order functions in a setting (e.g., embedded programming) where
dynamic memory allocation is not allowed or supported.


On Wednesday, March 5, 2014 1:08:05 AM UTC-5, H Zhang wrote:

Brandon Barker

unread,
Mar 6, 2014, 10:07:15 PM3/6/14
to ats-lan...@googlegroups.com
Where the end aim is to have a linear implementation and safety is not critical, I wonder if it is better to start out with linear mixed with unsafe, in order to make the transition easier later on (I do not know if this is true). It seems hard for most programmers to used to using unsafe.sats, but I am thinking of breaking the habit by deliberately trying to use it on some practice code as much as possible for a while.

gmhwxi

unread,
Mar 7, 2014, 12:41:43 PM3/7/14
to ats-lan...@googlegroups.com
Ultimately, programming is an art.

One should use whatever he or she finds to be the most effective approach that suits
his or her problems.
Reply all
Reply to author
Forward
0 new messages