Issues with late-binding templates in the same file?

51 views
Skip to first unread message

aditya siram

unread,
Jun 24, 2019, 7:54:12 PM6/24/19
to ats-lang-users
I'm trying to understand how templates work and can't get this example to compile:

#include "share/HATS/temptory_staload_bucs320.hats"

extern fun toString(s:string):void
extern fun {} with$print(s: !string):void

fun toString
(s: !string):void =
  let val
() = with$print(s) in  end

implement main0
(argc,argv) =
  let
    val s
= "hello world"
    val
() = toString(s) where {
      impltmp
with$print<>(s) = println! s
   
}
 
in
 
end



I get the following compilation errors:

In file included from template_dats.c:15:
template_dats
.c: In function toString_0’:
template_dats
.c:215:26: error: PMVtmpltcstmat undeclared (first use in this function)
 
ATSINSmove_void(tmpret0, PMVtmpltcstmat[0](with$print<>)(ATSPMVrefarg0(arg0))) ;
                         
^~~~~~~~~~~~~~
/home/deech/ATS/ComposeTalk2019/ATS/ATS-Temptory/ccomp/runtime/temptory_instrset.h:286:39: note: in definition of macro ATSINSmove_void
 
#define ATSINSmove_void(tmp, command) command
                                       
^~~~~~~
template_dats
.c:215:26: note: each undeclared identifier is reported only once for each function it appears in
 
ATSINSmove_void(tmpret0, PMVtmpltcstmat[0](with$print<>)(ATSPMVrefarg0(arg0))) ;
                         
^~~~~~~~~~~~~~
/home/deech/ATS/ComposeTalk2019/ATS/ATS-Temptory/ccomp/runtime/temptory_instrset.h:286:39: note: in definition of macro ATSINSmove_void
 
#define ATSINSmove_void(tmp, command) command
                                       
^~~~~~~
template_dats
.c:215:44: error: with$print undeclared (first use in this function); did you mean isprint’?
 
ATSINSmove_void(tmpret0, PMVtmpltcstmat[0](with$print<>)(ATSPMVrefarg0(arg0))) ;
                                           
^~~~~~~~~~
/home/deech/ATS/ComposeTalk2019/ATS/ATS-Temptory/ccomp/runtime/temptory_instrset.h:286:39: note: in definition of macro ATSINSmove_void
 
#define ATSINSmove_void(tmp, command) command
                                       
^~~~~~~
template_dats
.c:215:55: error: expected expression before ‘>’ token
 
ATSINSmove_void(tmpret0, PMVtmpltcstmat[0](with$print<>)(ATSPMVrefarg0(arg0))) ;
                                                       
^
/home/deech/ATS/ComposeTalk2019/ATS/ATS-Temptory/ccomp/runtime/temptory_instrset.h:286:39: note: in definition of macro ATSINSmove_void
 
#define ATSINSmove_void(tmp, command) command




Hongwei Xi

unread,
Jun 24, 2019, 7:58:51 PM6/24/19
to ats-lan...@googlegroups.com
toString needs to be implemented as a template:

extern
fun{} toString ...

--
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 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/658dd027-21a9-4f1b-a8eb-608c5a54b77f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages