Postiats and C errors with array

59 views
Skip to first unread message

Yannick Duchêne

unread,
Aug 6, 2018, 7:51:51 PM8/6/18
to ats-lang-users
I’m unsure if it’s something wrong with what I wrote (ex. may be it’s not allowed) or with Postiats. The sample below type‑checks, but compilation fails with an INTERROR message.

The sample:

        typedef row = @[int][3]
        val row1:row = @[int](1, 2, 3)
        val row2:row = @[int](4, 5, 6)
        var a = @[row][2](row1, row2)
        val a12 = a[1].[2]

On the second line, it fails with:

> INTERROR(pats_ccomp_dynexp): hidexp_ccomp: hde0 = HDEarrinit(HSEapp(HSEcst(atstkind_t0ype); HSEs2exp(S2Eextkind(atstype_int))); HDEint(3); HDEi0nt(1); HDEi0nt(2); HDEi0nt(3))


If I try this instead:

        typedef row = @[int][3]
        var row1:row = @[int](1, 2, 3)
        var row2:row = @[int](4, 5, 6)
        var a = @[row][2](row1, row2)
        val a12 = a[1].[2]

… Postiats can compile it, but I then I have numerous error while compiling C. Many of these errors mentions ATSstatmpdec and there are also C syntax errors.

Julian Fondren

unread,
Aug 6, 2018, 9:37:55 PM8/6/18
to ats-lang-users
Incidentally, this works:

#include "share/atspre_staload.hats"

typedef row = @(int, int, int)
val row1
: row = (1, 2, 3)
val row2
: row = (4, 5, 6)
var a = @[row](row1, row2)
val a12
= a[1].2

implement main0
() = println!(a12)

Hongwei Xi

unread,
Aug 6, 2018, 10:18:01 PM8/6/18
to ats-lan...@googlegroups.com

@[int][3] is the type for a flat int array of size 3.

Unfortunately, it is not fully supported at this point
(it can only be assigned to a var). Please use @(int, int, int)
instead.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/9695cba1-b5c0-463e-9356-60035b1bb142%40googlegroups.com.

Artyom Shalkhakov

unread,
Aug 6, 2018, 11:07:52 PM8/6/18
to ats-lang-users
вт, 7 авг. 2018 г. в 8:18, Hongwei Xi <gmh...@gmail.com>:

@[int][3] is the type for a flat int array of size 3.

Unfortunately, it is not fully supported at this point
(it can only be assigned to a var). Please use @(int, int, int)
instead.


Are you planning to support this in ATS3?

I guess another way to solve this problem right now is to use $extype for [row].
 
On Mon, Aug 6, 2018 at 7:51 PM, 'Yannick Duchêne' via ats-lang-users <ats-lan...@googlegroups.com> wrote:
I’m unsure if it’s something wrong with what I wrote (ex. may be it’s not allowed) or with Postiats. The sample below type‑checks, but compilation fails with an INTERROR message.

The sample:

        typedef row = @[int][3]
        val row1:row = @[int](1, 2, 3)
        val row2:row = @[int](4, 5, 6)
        var a = @[row][2](row1, row2)
        val a12 = a[1].[2]

On the second line, it fails with:

> INTERROR(pats_ccomp_dynexp): hidexp_ccomp: hde0 = HDEarrinit(HSEapp(HSEcst(atstkind_t0ype); HSEs2exp(S2Eextkind(atstype_int))); HDEint(3); HDEi0nt(1); HDEi0nt(2); HDEi0nt(3))


If I try this instead:

        typedef row = @[int][3]
        var row1:row = @[int](1, 2, 3)
        var row2:row = @[int](4, 5, 6)
        var a = @[row][2](row1, row2)
        val a12 = a[1].[2]

… Postiats can compile it, but I then I have numerous error while compiling C. Many of these errors mentions ATSstatmpdec and there are also C syntax errors.

--
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.

--
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.

Yannick Duchêne

unread,
Aug 7, 2018, 4:00:51 AM8/7/18
to ats-lang-users


Le mardi 7 août 2018 03:37:55 UTC+2, Julian Fondren a écrit :
Incidentally, this works:

#include "share/atspre_staload.hats"

typedef row = @(int, int, int)
val row1
: row = (1, 2, 3)
val row2
: row = (4, 5, 6)
var a = @[row](row1, row2)
val a12
= a[1].2

implement main0
() = println!(a12)


So with tuples. Indeed, I know it works, but I was trying some samples to document expressions of the form `[…] ` and wanted to try second level indexing of arrays.

By the way, I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats" seems often required.

Yannick Duchêne

unread,
Aug 7, 2018, 4:04:58 AM8/7/18
to ats-lang-users


Le mardi 7 août 2018 04:18:01 UTC+2, gmhwxi a écrit :

@[int][3] is the type for a flat int array of size 3.

Unfortunately, it is not fully supported at this point
(it can only be assigned to a var). Please use @(int, int, int)
instead.

Indeed, this works if there are only top‑level vars:

        #include "share/atspre_staload.hats"
        typedef row = @[int][3]
        var row:row = @[int](1, 2, 3)
        val r2 = row[2]

I just though although multiple dimension array types is not supported, it could be supported indirectly the way I tried it. It was not my matter, but may be for arrays with multiple dimension, using abstract types and external implementation may be an option, but I have never tried it.

Yannick Duchêne

unread,
Aug 7, 2018, 4:06:30 AM8/7/18
to ats-lang-users


Le mardi 7 août 2018 10:00:51 UTC+2, Yannick Duchêne a écrit :
[…]
By the way, I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats" seems often required.

Typo, sorry. I wanted to say  “I wonder why `#include "share/atspre_staload.hats"` **is not part** of the basics”.

Yannick Duchêne

unread,
Aug 7, 2018, 7:52:55 AM8/7/18
to ats-lang-users


Le mardi 7 août 2018 10:04:58 UTC+2, Yannick Duchêne a écrit :
[…] It was not my matter, but may be for arrays with multiple dimension, using abstract types and external implementation may be an option, but I have never tried it.

Or rather interpret one-dimension array as the storage of a multi‑dimensions array. 

Hongwei Xi

unread,
Aug 7, 2018, 1:36:06 PM8/7/18
to ats-lan...@googlegroups.com
>>I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats" seems often required.

If you use ATS to generate, say, JavaScript, then you need a different header.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.

Hongwei Xi

unread,
Aug 7, 2018, 1:39:54 PM8/7/18
to ats-lan...@googlegroups.com

>>multiple dimension array types is not supported,

We will support mutiple dimension arrays in ATS3. Such arrays
are a necessity for many machine learning algorithms.

On Tue, Aug 7, 2018 at 1:36 PM, Hongwei Xi <gmh...@gmail.com> wrote:

>>I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats" seems often required.

If you use ATS to generate, say, JavaScript, then you need a different header.
On Tue, Aug 7, 2018 at 4:00 AM, 'Yannick Duchêne' via ats-lang-users <ats-lang-users@googlegroups.com> wrote:


Le mardi 7 août 2018 03:37:55 UTC+2, Julian Fondren a écrit :
Incidentally, this works:

#include "share/atspre_staload.hats"

typedef row = @(int, int, int)
val row1
: row = (1, 2, 3)
val row2
: row = (4, 5, 6)
var a = @[row](row1, row2)
val a12
= a[1].2

implement main0
() = println!(a12)


So with tuples. Indeed, I know it works, but I was trying some samples to document expressions of the form `[…] ` and wanted to try second level indexing of arrays.

By the way, I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats" seems often required.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.

Yannick Duchêne

unread,
Aug 7, 2018, 3:20:57 PM8/7/18
to ats-lang-users


Le mardi 7 août 2018 19:39:54 UTC+2, gmhwxi a écrit :

>>multiple dimension array types is not supported,

We will support mutiple dimension arrays in ATS3. Such arrays
are a necessity for many machine learning algorithms.

Yes, in some applications, arrays are as muche ubiquitous as dictionaries are in some other applications. By he way, unless I missed it, Python surprisingly does not have direct support for arrays, it only has lists. 



Le mardi 7 août 2018 19:36:06 UTC+2, gmhwxi a écrit :

>>I wonder why `#include "share/atspre_staload.hats"` of the basics which are always loaded by default, because "share/atspre_staload.hats"  seems often required.

If you use ATS to generate, say, JavaScript, then you need a different header.

(shy) yes. May be an idea for ATS3, could be selection of includes based on the target language. Ex. there could be directories named after the target containing includes whose content depends on that language. The include statement would be target neutral, but the file actually included would depend on the target language.

Hongwei Xi

unread,
Aug 7, 2018, 3:40:16 PM8/7/18
to ats-lan...@googlegroups.com
>>Python surprisingly does not have direct support for arrays,

Python is not famous for being effcient :)



--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.

Yannick Duchêne

unread,
Aug 7, 2018, 4:34:45 PM8/7/18
to ats-lang-users


Le mardi 7 août 2018 21:40:16 UTC+2, gmhwxi a écrit :
>>Python surprisingly does not have direct support for arrays,

Python is not famous for being effcient :)

I know, at least 40x worse than the equivalent in any imperative language. I’m using it rather for its terse syntax (and because it’s everywhere), but I badly miss typing with it (PyLint helps a bit to workaround this, but just a bit).

Talking about it, the first thing I will do when the documentation I attempt to write will be finished, is to try to port my Postiats utilities to ATS2 and see how much I can have something as terse as the Python version. I believe it will be a good real world exercice (for know, I just tested ATS2 with propositions based proving three years ago, and I gave up, because I wanted too much from it).
Reply all
Reply to author
Forward
0 new messages