Where is "FILE" view type on ATS2?

It is in ${PATSHOME}/libc/SATS/stdio.sats; it is called FILE_v.On Sat, May 9, 2015 at 4:28 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi all,

I start to port atsdoc into ATS2.
However, following error occurs.

$ make |& head -2
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c atsdoc_main.dats
/home/kiwamu/src/ATS-Postiats.masterq/libatsdoc/SATS/libatsdoc_lexbuf.sats:
1979(line=60, offs=10) -- 1983(line=60, offs=14): error(2):
unrecognized static identifier [FILE].

It’s caused by following code.

fun lexbuf_initialize_filp
  {m:file_mode} {l:addr} (
  pfmod: file_mode_lte (m, r)
, pffil: FILE m @ l
| r: &lexbuf? >> lexbuf, p: ptr l
) : void // end of [lexbuf_initialize_filp]

Where is “FILE” view type on ATS2?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN


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/CAEvX6dmx%3Dz7uRBLhDr8TfZit2VRkCua_JTKt6jozfwBMN-7njg%40mail.gmail.com
.

I would implement the function in ATS2 as follows:

implement
comarglst_parse
{n} (argc, argv) = let
//
val p = $UN.cast{ptr}(argv)
//
implement
tabulate$fopr (i) =
comarg_parse($UN.ptr0_get_at (p, i))
//
in
list_tabulate (argc)
end // end of [comarglst_parse]On Wednesday, May 13, 2015 at 2:36:07 AM UTC-4, Kiwamu Okabe wrote:

Hi Hongwei,

On Sat, May 9, 2015 at 8:51 PM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:

It is in ${PATSHOME}/libc/SATS/stdio.sats; it is called FILE_v.

Thank’s. I got some progress.

GitHub - master-q/ATS-Postiats at feature/atsdoc

But I have found the other error. How to fix it?

The error is following:

$ make |& head -2 
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c 
atsdoc_main.dats 
/home/kiwamu/src/ATS-Postiats.masterq/utils/atsdoc/atsdoc_main.dats: 
3191(line=103, offs=29) -- 3203(line=103, offs=41): error(3): the 
dynamic expression is expected to be a pointer. 

And code is following:

implement 
comarglst_parse 
  {n} (argc, argv) = let 
  viewtypedef arglst (n: int) = list_vt (comarg, n) 
  fun loop {i:nat | i <= n} {l:addr} .<n-i>. 
    (pf0: arglst 0 @ l | argv: &(@[string][n]), i: int i, p: ptr l) 
    :<cloref> (arglst (n-i) @ l | void) = 
    if i < argc then let 
      val+ ~list_vt_nil () = !p 
      val arg = comarg_parse (argv.[i]) 
      val lst0 = list_vt_cons (arg, list_vt_nil ()) 
      val+ list_vt_cons (_, lst) = lst0 
      val (pf | ()) = loop (view@ (!lst) | argv, i+1, lst) // <= Here! 
    in 
      fold@ lst0; !p := lst0; (pf0 | ()) 
    end else (pf0 | ()) 
  val lst0 = list_vt_nil {comarg} () 
  val (pf | ()) = loop (view@ lst0 | argv, 0, lst0) // tail-call 
  prval () = view@ lst0 := pf 
in 
  lst0 
end // end of [comarglst_parse] 

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

val (pf | ()) = loop (view@ (!lst) | argv, i+1, lst) // <= Here!

should be written as follows in ATS2:

val (pf | ()) = loop (view@lst | argv, i+1, addr@lst)On Wed, May 13, 2015 at 2:35 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi Hongwei,

On Sat, May 9, 2015 at 8:51 PM, Hongwei Xi gmh...@gmail.com wrote:

It is in ${PATSHOME}/libc/SATS/stdio.sats; it is called FILE_v.

Thank’s. I got some progress.

GitHub - master-q/ATS-Postiats at feature/atsdoc

But I have found the other error. How to fix it?

The error is following:

$ make |& head -2
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c atsdoc_main.dats
/home/kiwamu/src/ATS-Postiats.masterq/utils/atsdoc/atsdoc_main.dats:
3191(line=103, offs=29) -- 3203(line=103, offs=41): error(3): the
dynamic expression is expected to be a pointer.

And code is following:

implement
comarglst_parse
  {n} (argc, argv) = let
  viewtypedef arglst (n: int) = list_vt (comarg, n)
  fun loop {i:nat | i <= n} {l:addr} .<n-i>.
    (pf0: arglst 0 @ l | argv: &(@[string][n]), i: int i, p: ptr l)
    :<cloref> (arglst (n-i) @ l | void) =
    if i < argc then let
      val+ ~list_vt_nil () = !p
      val arg = comarg_parse (argv.[i])
      val lst0 = list_vt_cons (arg, list_vt_nil ())
      val+ list_vt_cons (_, lst) = lst0
      val (pf | ()) = loop (view@ (!lst) | argv, i+1, lst) // <= Here!
    in
      fold@ lst0; !p := lst0; (pf0 | ())
    end else (pf0 | ())
  val lst0 = list_vt_nil {comarg} ()
  val (pf | ()) = loop (view@ lst0 | argv, 0, lst0) // tail-call
  prval () = view@ lst0 := pf
in
  lst0
end // end of [comarglst_parse]

Thank’s,

Kiwamu Okabe at METASEPI DESIGN


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/CAEvX6dn%3D8xXkN4npkJ_C7PrcW2JZKm48xS8p_w6FyLF6JrPOZw%40mail.gmail.com
.

Sorry for my frequent mail.

Not all. Thanks for doing it.

Maybe we could re-write ATS2 in ATS2 someday :slight_smile:

The problem you encountered is due to fopen being given
different types in ATS1 and ATS2. Here is my suggestion:

Create a file, say, atsdoc_mylib.dats, and then put into it
various library functions you need and their ATS1 types. Instead of
using ATS2 library, you try to use atsdoc_mylib.dats. I will be happy
to set up this for you if you like. Of course, it is always more fun if
you try it on your own :)On Wednesday, May 13, 2015 at 6:56:07 AM UTC-4, Kiwamu Okabe wrote:

Hi Hongwei,
Sorry for my frequent mail.
I should progress inch by inch.

On Wed, May 13, 2015 at 5:07 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

implement
comarglst_parse
{n} (argc, argv) = let
//
val p = $UN.cast{ptr}(argv)
//
implement
tabulate$fopr (i) =
comarg_parse($UN.ptr0_get_at (p, i))
//
in
list_tabulate (argc)
end // end of [comarglst_parse]

I think your code is applied with some patch.
Next problem is fopen. Following error occurs while fopen fucntion should
return view and dynamic value.

$ make |& head -2 
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c 
atsdoc_main.dats 
/home/kiwamu/src/ATS-Postiats.masterq/utils/atsdoc/atsdoc_main.dats: 
5274(line=218, offs=7) -- 5288(line=218, offs=21): error(3): the 
tuple/record pattern is ill-typed. 

The code is following:

fun outcode_set_filename 
  (path: string): void = let 
  val (pfopt | filp) = fopen (path, file_mode_w) // <= Here! 
in 
// 
if filp > the_null_ptr then let 
  prval Some_v (pffil) = pfopt 
  val filp = __cast (pffil | filp) where { 
    extern castfn __cast {m:fm} {l:addr} (pf: FILE_v (l, m) | p: ptr l): 
FILEref 
  } // end of [val] 
in 
  outcode_set (OUTCHANptr (filp)) 
end else let 
  prval None_v () = pfopt in outcode_set (OUTCHANref (stderr_ref)) 
end // end of [if] 
// 
end // end of [outcode_set_filename] 

Thank’s,

Kiwamu Okabe at METASEPI DESIGN