Some examples that might be helpful

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.

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.On Wednesday, March 5, 2014 9:55:31 AM UTC-5, gmhwxi wrote:

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:

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

On Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

Thanks for sharing it!

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

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!On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

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:

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

On Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

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.

HaitaoOn Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

I forgot the mention that I added objectify/unobjectify into
prelude/arrayptr.
Give them a try if you have time.On Tuesday, March 4, 2014 9:49:26 PM UTC-5, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

I’m pretty sure functions are first class objects, but not function
templates.

Brandon Barker
brandon…@gmail.comOn Wed, Mar 5, 2014 at 1:11 AM, Brandon Barker brandon...@gmail.comwrote:

My impression is use of GC is often done while prototyping something.

For stack allocated closures see this thread:
Redirecting to Google Groups

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

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

On Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.


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.comhttps://groups.google.com/d/msgid/ats-lang-users/e373105c-2177-4c44-801d-9a9e5d916f75%40googlegroups.com?utm_medium=email&utm_source=footer
.

My impression is use of GC is often done while prototyping something.

For stack allocated closures see this thread:
Redirecting to Google Groups Wednesday, March 5, 2014 1:08:05 AM UTC-5, H Zhang wrote:

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

On Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.

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.On Thursday, March 6, 2014 10:07:15 PM UTC-5, Brandon Barker wrote:

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.

On Wednesday, March 5, 2014 9:55:31 AM UTC-5, gmhwxi wrote:

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:

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

On Tuesday, March 4, 2014 6:49:26 PM UTC-8, gmhwxi wrote:

Thanks for sharing it!

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

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!

On Tuesday, March 4, 2014 10:57:55 AM UTC-5, chotu s wrote:

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.

Bitbucket

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.