Is it correct that patsopt creates .c file while the .dats file occurs type error?

43 views
Skip to first unread message

Kiwamu Okabe

unread,
Jan 4, 2015, 5:56:19 AM1/4/15
to ats-lang-users, ats-lang-users
Hi all,

Is it correct that patsopt creates .c file while the .dats file occurs
type error?

```
$ rm -f hoge.c
casper$ cat hoge.dats
implement main0 (a) = println! ("Hello world!")
casper$ patsopt -o hoge.c -d hoge.dats
/home/kiwamu/tmp/hoge.dats: 11(line=1, offs=11) -- 48(line=1,
offs=48): error(2): there is no suitable dynamic constant declared for
[main0].
TRANS2: there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
casper$ ls -l hoge.c
-rw-r--r-- 1 kiwamu kiwamu 0 Jan 4 19:54 hoge.c
```

I think "hoge.c" should not be created on this case.

Thank's,
--
Kiwamu Okabe at METASEPI DESIGN

Kiwamu Okabe

unread,
Jan 5, 2015, 2:50:51 AM1/5/15
to ats-lang-users, ats-lang-users
Hi,

So, this issue is very serious.
Please imagine following Makefile.

https://github.com/metasepi/linux-bohai-s1/blob/bohai-s1/metasepi/scripts/Makefile.ats
https://github.com/metasepi/linux-bohai-s1/blob/bohai-s1/net/sunrpc/Makefile

If you enable ".SECONDARY: ${obj}/xdr_dats.c" line, then xdr_dats.c
file will not be removed while compiling.
Please imagine xdr.dats file includes some type error, then ATS2
compiler creates EMPTY xdr_dats.c file and remain it!
On next compile, you will find compile error on EMPTY xdr_dats.c file,
however true reason is at xdr.dats file's error.
It's messy....

gmhwxi

unread,
Jan 5, 2015, 5:49:36 AM1/5/15
to ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net, kiw...@debian.or.jp
This issue requires some thoughts.

Patsopt can be used to compile several DATS files into a single C file.
If Patsopt encounters a failure in the middle of a multi-file compilation,
deleting the entire file may not be a good choice.

Also, I want to point out that a program in ATS may be still unable to be
compiled into proper C code after the program passes typechecking.
Sometimes, one needs to go over the (partially) generated C code in order
to figure out what went wrong.

Shea Levy

unread,
Jan 5, 2015, 6:32:10 AM1/5/15
to ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net, kiw...@debian.or.jp
For the Makefile issue, I suppose one can work around it by compiling to a temporary file and moving to the real file if compilation succeeds (all in the same rule of course)

-- 
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/c0ea7629-6dc7-4ff8-aaf4-4eda4a5e7111%40googlegroups.com.

gmhwxi

unread,
Jan 5, 2015, 4:58:16 PM1/5/15
to ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net, kiw...@debian.or.jp
Yes, this would be a reasonable solution for the moment.

If one just uses patsopt to compile a single DATS file, then writing a simple wrapper
around patsopt should be able to address the issue adequately.

My design for patsopt ensures that the closing of an opened file is postponed until the last
possible moment. Instead of allowing an EMPTY file to be generated, I am now thinking about
putting in it a directive like:

#error(patsopt: there were errors ...)

john skaller

unread,
Jan 5, 2015, 5:43:17 PM1/5/15
to gmhwxi, ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net

On 06/01/2015, at 8:58 AM, gmhwxi wrote:

> My design for patsopt ensures that the closing of an opened file is postponed until the last
> possible moment.

Er .. why leave any files open at all?

Save all the text into a buffer. Write the buffer in one go at the end.

--
john skaller
ska...@users.sourceforge.net
http://felix-lang.org



Hongwei Xi

unread,
Jan 5, 2015, 9:19:13 PM1/5/15
to ats-lan...@googlegroups.com, ats-lang-users

---------- Forwarded message ----------
From: Hongwei Xi <gmh...@gmail.com>
Date: Mon, Jan 5, 2015 at 9:14 PM
Subject: Re: [ats-lang-users] Is it correct that patsopt creates .c file while the .dats file occurs type error?


That would be nice :)

But it needs quite significant effort.

The input/output part of ATS2 should be modularized in the future. The work can probably be combined with the effort to port ATS2 to Windows (not via Cygwin).

gmhwxi

unread,
Jan 6, 2015, 2:54:50 AM1/6/15
to ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net, kiw...@debian.or.jp

Instead of generating an empty file, patsopt now generates a file containing
one #error(...) directive if it encounters an error during typechecking, When such
a file is compiled, the programmer is reminded of what went wrong. I will probably
replace #error with something like PATSOPT_ERROR to make it easier for searching.

Kiwamu Okabe

unread,
Jan 7, 2015, 11:54:53 PM1/7/15
to ats-lang-users, ats-lang-users
Hi Shea,

On Mon, Jan 5, 2015 at 8:32 PM, Shea Levy <sh...@shealevy.com> wrote:
> For the Makefile issue, I suppose one can work around it by compiling to a
> temporary file and moving to the real file if compilation succeeds (all in
> the same rule of course)

Ah, my issue is an already-answered question.
I'll try to do this trick.

Kiwamu Okabe

unread,
Jan 8, 2015, 12:03:18 AM1/8/15
to ats-lang-users, ats-lang-users
Hi Hongwei,

On Mon, Jan 5, 2015 at 7:49 PM, gmhwxi <gmh...@gmail.com> wrote:
> This issue requires some thoughts.
>
> Patsopt can be used to compile several DATS files into a single C file.
> If Patsopt encounters a failure in the middle of a multi-file compilation,
> deleting the entire file may not be a good choice.
>
> Also, I want to point out that a program in ATS may be still unable to be
> compiled into proper C code after the program passes typechecking.
> Sometimes, one needs to go over the (partially) generated C code in order
> to figure out what went wrong.

Um.... I think I can understand your situation....
And, I would like to use patsopt such like gcc, and also recommend it for the
other programmer. That means that we hope patsopt has a behavior as the
other products.

Then, this issue should be assign me.

https://github.com/githwxi/ATS-Postiats/issues/116
Reply all
Reply to author
Forward
0 new messages