List filling causing "undeclared (first use in function)" error

31 views
Skip to first unread message

aditya siram

unread,
Dec 3, 2017, 5:43:28 PM12/3/17
to ats-lang-users
Hi all,
I have a simple program that fills a list with a bunch of characters and a driver:
#include "share/atspre_staload.hats"

fun
{t:t0p} fill_list
 
{n:nat}
 
(
    size
:ssize_t n,
    c
: t
 
): list_vt(t,n) =
  let
    fun loop
     
{i:nat | i <= n}
     
.<i>.
     
(
        size
: ssize_t i,
        c
: t,
        res
: list_vt(t, n-i)
     
): list_vt(t,n) =
     
if (size = i2ssz(0))
     
then res
     
else loop(pred size, c, list_vt_cons(c,res))
 
in
    loop
(size,c,list_vt_nil())
 
end

implement main0
(argc, argv) =
  let
    val x
= fill_list(i2ssz(10), 'x')
 
in
   
begin
      println
! (" testing: ", x);
      list_vt_free
(x)
   
end
 
end

Running this should print 10 'x's instead I get:
> patscc -g -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -g -I/home/deech/Downloads/ATS/ATS2/contrib -o xs xs.dats -latslib

In file included from xs_dats.c:15:0:
xs_dats
.c: In function ATSLIB_056_prelude__fprint_val__31__1’:
xs_dats
.c:2292:22: error: PMVtmpltcstmat undeclared (first use in this function)
ATSINSmove(tmp60__1, PMVtmpltcstmat[0](tostrptr_val<[1]>)(arg1)) ;
[1]: S2EVar(5259)
^
/home/deech/Downloads/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ATSINSmove
#define ATSINSmove(tmp, val) (tmp = val)
^~~
xs_dats
.c:2292:22: note: each undeclared identifier is reported only once for each function it appears in
ATSINSmove(tmp60__1, PMVtmpltcstmat[0](tostrptr_val<[1]>)(arg1)) ;
[1]: S2EVar(5259)
 

Any idea what I'm doing wrong?
Thanks!
-deech

Hongwei Xi

unread,
Dec 3, 2017, 5:51:23 PM12/3/17
to ats-lan...@googlegroups.com
You need to provide a template parameter explicitly:

fill_list<char>

Strictly speaking, template parameters are always needed.
Some heuristics are currently used to synthesize template parameters but
unfortunately they do not always succeed.


--
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/f53efa09-3260-46b2-b915-e7859d167d88%40googlegroups.com.

aditya siram

unread,
Dec 3, 2017, 6:54:26 PM12/3/17
to ats-lang-users
Ah cool, I had tried previously with '<charNZ>' and that seemed to have similar issues. This is a minimal example. How would I add sort constraints here, like eg. 'charNZ' or 'nat'?
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.

Hongwei Xi

unread,
Dec 3, 2017, 7:01:31 PM12/3/17
to ats-lan...@googlegroups.com
The problem is that overloading and dependent types do not go well together.
You need to be more explicit if you want to pass 'charNZ':

  implement main0(argc, argv) =
    let
      val xs = fill_list<charNZ>(i2ssz(10), 'x')
    in
      begin
        print("testing: ");
        print_list_vt<char>(xs); println!(); list_vt_free(xs)
      end
    end


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.
Reply all
Reply to author
Forward
0 new messages