Fwd: [ats-lang-users] ATS2-0.1.3 released

74 views
Skip to first unread message

Hongwei Xi

unread,
Sep 29, 2014, 1:39:10 PM9/29/14
to ats-lan...@googlegroups.com

---------- Forwarded message ----------
From: Hongwei Xi <hw...@bu.edu>
Date: Mon, Sep 29, 2014 at 1:37 PM
Subject: [ats-lang-users] ATS2-0.1.3 released
To: ats-lan...@lists.sourceforge.net


Hi,

I am glad to announce the release of ATS2-0.1.3.

The official website for ATS is: http://www.ats-lang.org

The following packages are included in this release:

ATS2-Postiats-0.1.3.tgz
ATS2-Postiats-include-0.1.3.tgz

After installing ATS-Postiats-include, one can compile
the C code generated from ATS source without installing
the ATS compiler. So a convenient way to distribute software
written in ATS is to simply release the C code generated
from the ATS source.

See below for some major additions and changes in ATS2-0.1.3.

Cheers!

--Hongwei

This is the 12th release of ATS2, the successor of the ATS
programming language. The compiler for ATS2 is given the name
ATS/Positats, ATS2/Postiats or simply Postiats.

The official website for ATS is:

http://www.ats-lang.org

ATS-Postiats is hosted at github:

https://github.com/githwxi/ATS-Postiats

Major releases of ATS2 are available at:

https://sourceforge.net/projects/ats2-lang/

Major releases of external packages for ATS2 are available at:

https://sourceforge.net/projects/ats2-lang-contrib/

Here is a list of major additions and changes since the last release:

1. Adding support for dot-notation overloading in assignments.
    This feature is mostly for interacting ATS with other languages.
    See ATS2TUTORIAL/CHAP_DOTOVERLD for a short article of explanation.
2. Adding support for functional style o dot-notation overloading.
    This feature makes it very convenient for ATS to interact with OOP.
3. Generally improving level-2 jsonization (pats_dynexp2_jsonize)
4. Adding support for extvar decl. (which is different from $extval):
    extvar "external_name" = internal_value
5. ATS_DYNLOADFLAG is set to 1 by default only for DATS-files. So
    dynloading SATS-files is no longer necessary (but it is still harmless).
6. Adding support for $extmcall(ret_type, obj, "method", arglst),
    which translates into the method invocation: obj.method(arglst)
7. Adding -D_ATS_ARRAY_FIELD to safe-guard using array fields in records.

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
ats-lang-users mailing list
ats-lan...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ats-lang-users

Brandon Barker

unread,
Oct 2, 2014, 4:31:14 PM10/2/14
to ats-lang-users
Regarding dot-notation overloading for linear values, I can appreciate that the handling might need to be different, but I don't actually see where the linearity comes in to play. I also don't really understand the statement:  Instead, one needs to use c0.get as the function inside a function call in order to call counter_get on c0:

val n0 = c0.get() // = counter_get(c0)

--
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.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrXVW-cXge0GccpOjFZf6p3CN5oLggbbaH2LxX-E916uQ%40mail.gmail.com.



--
Brandon Barker
brandon...@gmail.com

gmhwxi

unread,
Oct 2, 2014, 6:38:51 PM10/2/14
to ats-lan...@googlegroups.com

In a function call, you have a function and some arguments; c0.get should be the
function part inside a function call.

Brandon Barker

unread,
Oct 2, 2014, 7:00:50 PM10/2/14
to ats-lang-users
It seems like in that case 'get' (or 'get()') would be the function part of the function all, and c0 would be the rest of it.

Also, why is it not an issue for nonlinear values; why must linear values require () for their dot-notation overloading? I suspect it may be a not so interesting complexity in the grammar, in which case, I'm happy to stop there :). 

gmhwxi

unread,
Oct 2, 2014, 7:08:58 PM10/2/14
to ats-lan...@googlegroups.com

You can do

foo.x := x0

but you cannot do

foo.x() := x0

The plain dot notation and the functional dot notation have to be handled differently.

gmhwxi

unread,
Oct 2, 2014, 7:11:49 PM10/2/14
to ats-lan...@googlegroups.com
>>In a function call, you have a function and some arguments; c0.get should be the
>>function part inside a function call.

In programming languages, the right terminology for this is to say that c0.get must be
in an *applied* position.

Barry Schwartz

unread,
Oct 2, 2014, 7:47:35 PM10/2/14
to ats-lan...@googlegroups.com
gmhwxi <gmh...@gmail.com> skribis:
> >>In a function call, you have a function and some arguments; c0.get should
> be the
> >>function part inside a function call.
>
> In programming languages, the right terminology for this is to say that
> c0.get must be
> in an *applied* position.

IMO this OOPish notation is confusing, but that’s not your fault. :)
The problem (obvious after some use of Python) is that the thing to
the left of the period is an argument, and so has to be thought of as
if it were the first thing after the ‘(’.

Still, it might prove useful even for OOP-skeptical me, one day.

(20 years ago I was OOP-boosting, but now I am OOP-skeptical. :D )

Brandon Barker

unread,
Oct 2, 2014, 7:49:57 PM10/2/14
to ats-lang-users
Sort of similar for me, though less expert and a more condense timeline :)

>
> --
> 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.
> Visit this group at http://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/20141002234730.GA9770%40crud.



--
Brandon Barker
brandon...@gmail.com

Brandon Barker

unread,
Oct 3, 2014, 9:49:11 AM10/3/14
to ats-lang-users
On Thu, Oct 2, 2014 at 7:47 PM, Barry Schwartz <chemoe...@chemoelectric.org> wrote:
gmhwxi <gmh...@gmail.com> skribis:
> >>In a function call, you have a function and some arguments; c0.get should
> be the
> >>function part inside a function call.
>
> In programming languages, the right terminology for this is to say that
> c0.get must be
> in an *applied* position.

IMO this OOPish notation is confusing, but that’s not your fault. :)
The problem (obvious after some use of Python) is that the thing to
the left of the period is an argument, and so has to be thought of as
if it were the first thing after the ‘(’.


I actually use python a bit, so this part wasn't confusing for me, and indeed reminded me of python immediately.
I still think it is convenient - you can
tab-complete a method name in IPython. But, if you had a functionally oriented (or type oriented?) IPython,
maybe you could tab complete existing object names for a particular function.

This seems easier to do in some sense, as it is usually much easier to remember a function name and type
that in than a variable  name.




 
Still, it might prove useful even for OOP-skeptical me, one day.

(20 years ago I was OOP-boosting, but now I am OOP-skeptical. :D )
--
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.
Visit this group at http://groups.google.com/group/ats-lang-users.



--
Brandon Barker
brandon...@gmail.com

Brandon Barker

unread,
Oct 3, 2014, 9:49:44 AM10/3/14
to ats-lang-users
Ah, yes now I see the intent a bit better - thanks.

Brandon Barker

unread,
Oct 3, 2014, 10:04:48 AM10/3/14
to ats-lang-users
Is there any way to use $extmcall in C - perhaps if the object is a struct and one of its fields is a function pointer? Admittedly this is probably a rare situation, but am just curious.

Sorry for being possibly obtuse once again, but could you post a short example about the use case for -D_ATS_ARRAY_FIELD?


On Mon, Sep 29, 2014 at 1:39 PM, Hongwei Xi <gmh...@gmail.com> wrote:

--
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.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrXVW-cXge0GccpOjFZf6p3CN5oLggbbaH2LxX-E916uQ%40mail.gmail.com.



--
Brandon Barker
brandon...@gmail.com

Hongwei Xi

unread,
Oct 3, 2014, 3:12:23 PM10/3/14
to ats-lan...@googlegroups.com
Yes, you can use $extmcall in C:

#define ATSextmcall(obj, mtd, funarg) (obj->mtd)funarg

It is just not very useful.

One can readily do OOP in C. See http://www.cs.rit.edu/~ats/books/ooc.pdf

However, C does not have special syntax for supporting OOP. Take a look at GTK.
Basically, a method call looks like this: method(object, arg_1, ..., arg_n).

You can actually use the (functional) dot-notation overloading in ATS to make these
calls look like calls in OOP: object.method(arg_1, ..., arg_n).



Hongwei Xi

unread,
Oct 3, 2014, 3:18:10 PM10/3/14
to ats-lan...@googlegroups.com
>> but could you post a short example about the use case for -D_ATS_ARRAY_FIELD?

Say you declare a type foo as follows:

typedef foo = @{
  field= int
, field2= string
, field3= @[int][5] // this cannot be handled
}

ATS will not be able to handle it correctly. Such a type should be given a name in C and then
this name can be used in ATS. However, the following type declaration can be handled in ATS:

typedef foo2 = @{
  field= int
, field2= string
, field3= @[int][] // this can be handled correctly.

If you want foo2 to be handled, then you need to have -D_ATS_ARRAY_FIELD when compiling.


On Fri, Oct 3, 2014 at 10:04 AM, Brandon Barker <brandon...@gmail.com> wrote:

Barry Schwartz

unread,
Oct 3, 2014, 3:34:53 PM10/3/14
to ats-lan...@googlegroups.com
Hongwei Xi <gmh...@gmail.com> skribis:
> One can readily do OOP in C. See http://www.cs.rit.edu/~ats/books/ooc.pdf
>
> However, C does not have special syntax for supporting OOP. Take a look at
> GTK.
> Basically, a method call looks like this: method(object, arg_1, ..., arg_n).

Be prepared for debugging nightmares, too, if my experience counts for
much.

Brandon Barker

unread,
Oct 3, 2014, 4:28:19 PM10/3/14
to ats-lang-users
This seems to raise two questions:

1) Why can't 'foo' be handled?
It seems to not be an issue of typechecking, as I can make an example using 'foo' that typechecks. But of course it errors on compilation. 

2) If 'foo2' can be handled, why require a compiler argument?

My guess for this one is that having arrays of arbitrary size can be unsafe (without using dependent types for array length), so the default is to disallow it. This seems especially dangerous for an unboxed record as it might create some issues on the stack?

Thanks,


Hongwei Xi

unread,
Oct 3, 2014, 4:44:49 PM10/3/14
to ats-lan...@googlegroups.com
>>1) Why can't 'foo' be handled?
>>It seems to not be an issue of typechecking, as I can make an example using 'foo' that typechecks. But of course it errors on >>compilation.

I would say that being able to handle 'foo' does not really make ATS more useful.
For one thing, there is no easy way in ATS to initialize array fields in a safe manner.
While it can be done, it is so involved that I doubt anyone wants to do it after going
through the trouble once.

>>2) If 'foo2' can be handled, why require a compiler argument?

To make sure that the user really knows what he is doing.


Brandon Barker

unread,
Oct 3, 2014, 6:02:29 PM10/3/14
to ats-lang-users
On Fri, Oct 3, 2014 at 4:44 PM, Hongwei Xi <gmh...@gmail.com> wrote:
>>1) Why can't 'foo' be handled?
>>It seems to not be an issue of typechecking, as I can make an example using 'foo' that typechecks. But of course it errors on >>compilation.

I would say that being able to handle 'foo' does not really make ATS more useful.
For one thing, there is no easy way in ATS to initialize array fields in a safe manner.
While it can be done, it is so involved that I doubt anyone wants to do it after going
through the trouble once.

What am I missing here? (this typechecks with the above 'foo' type, but does not compile):

val x: foo = @{field = 1, field2 = "blah", field3 = @[int][5](1)}

This looks safe to me; field3 should be an integer array of length 5 with each entry initialized to 1?

 

Hongwei Xi

unread,
Oct 3, 2014, 7:54:33 PM10/3/14
to ats-lan...@googlegroups.com
It is safe, but where do you store a value like @[int][5](1)?

Brandon Barker

unread,
Oct 4, 2014, 6:33:23 PM10/4/14
to ats-lan...@googlegroups.com
I thought this implied it was stack allocated. I also thought that record types starting with '@' are stack allocated unless explicitly put on the heap (just like a struct in c), so it would seem these would be compatible. 

But something does seem off. I actually thought 

val x = ...

implied stack allocation by default, unless some function using malloc is employed or a nonlinear type is used. While, both of these typecheck, only the latter compiles:

val my_array = @[int][5](1)

var my_array = @[int][5](1)


What am I missing/forgetting in this case?

Thanks,

gmhwxi

unread,
Oct 4, 2014, 8:52:53 PM10/4/14
to ats-lan...@googlegroups.com
Assume that alloca should be avoided.
Then an array-value @[int][n](1) cannot be handled unless n
is a constant.

As a value, @[int][n](1) is read-only.

I just don't feel that it is worth the effort to support this
kind of read-only arrays in ATS. If it is really needed, then
there is always a way to do it in C.

>>var my_array = @[int][5](1)

This is

Brandon Barker

unread,
Oct 6, 2014, 2:17:40 PM10/6/14
to ats-lang-users
On Sat, Oct 4, 2014 at 8:52 PM, gmhwxi <gmh...@gmail.com> wrote:
> Assume that alloca should be avoided.
> Then an array-value @[int][n](1) cannot be handled unless n
> is a constant.
>
> As a value, @[int][n](1) is read-only.
>
> I just don't feel that it is worth the effort to support this
> kind of read-only arrays in ATS. If it is really needed, then
> there is always a way to do it in C.

That sounds reasonable and fair. I just didn't know that was the issue at hand.
I'll try to add some of this to the wiki soon.
> https://groups.google.com/d/msgid/ats-lang-users/a937a7d8-de09-4efd-91a6-a5097c614142%40googlegroups.com.



--
Brandon Barker
brandon...@gmail.com
Reply all
Reply to author
Forward
0 new messages