How to write a closure taking a ref val?

23 views
Skip to first unread message

Brandon Barker

unread,
Feb 20, 2014, 5:31:39 PM2/20/14
to ats-lan...@googlegroups.com
I've had similar errors before but in different contexts I think:
d1exp_tr_arg_body_ann: the function argument cannot be ascribed refval types.


extern
fun genes_meanvar
  (xs: !genes, emap: GDMap, smap: GDMap): (double, double)

extern
fun gmeanvar_makeclo(GDMap, GDMap):
  genes -<cloref> (double, double)
//
implement
gmeanvar_makeclo(emap, smap) =
  lam(xs: !genes) => genes_meanvar(xs, emap, smap)



Message has been deleted

gmhwxi

unread,
Feb 20, 2014, 7:16:33 PM2/20/14
to ats-lan...@googlegroups.com

extern
fun gmeanvar_makeclo(GDMap, GDMap):
  genes -<cloref> (double, double)

should be

extern
fun gmeanvar_makeclo(GDMap, GDMap):
  (!genes) -<cloref> (double, double)

Brandon Barker

unread,
Feb 20, 2014, 8:06:31 PM2/20/14
to ats-lan...@googlegroups.com
Woops, that makes sense. However, it seems I still get the same error.

I updated ATS-Postiats to HEAD to see if that would help and I can't seem to build:
/media/RAID5/home/brandon/ATS-Postiats/src/pats_ccomp_dynexp_dats.c:3799: undefined reference to `_2media_2RAID5_2home_2brandon_2ATS_2dPostiats_2src_2pats_ccomp_dynexp_2edats__hidexp_ccomp_ret_fixinit'

gmhwxi

unread,
Feb 20, 2014, 8:47:04 PM2/20/14
to ats-lan...@googlegroups.com
Your version of ATS is too new :)

Brandon Barker

unread,
Feb 20, 2014, 9:24:38 PM2/20/14
to ats-lan...@googlegroups.com
When I use a slightly less recent versio
abstype mytype

extern
fun myfun
  (!mytype, x: int): int

extern
fun my_makeclo(int): (!mytype) -<cloref> int
//
implement
my_makeclo(x) =
 lam(xs: !mytype) => myfun(xs, x)


n (but one that compiles) with this test case, the same problem occurs:

gmhwxi

unread,
Feb 20, 2014, 10:26:36 PM2/20/14
to ats-lan...@googlegroups.com
This one works.

abstype mytype

extern
fun myfun
 
(!mytype, x: int): int

extern

fun my_makeclo
(int): (!mytype) -<cloref1> int

implement
my_makeclo
(x) = lam(xs) => myfun(xs, x)


Partially annotated functions should in general be avoided.

Brandon Barker

unread,
Feb 20, 2014, 10:33:26 PM2/20/14
to Hongwei Xi, ats-lan...@googlegroups.com

Thanks. Partially annotated refers to using a closure to hide data used as inputs?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/312ce9c3-bb8d-4a2b-8e3a-f752faa3805d%40googlegroups.com.

Brandon Barker

unread,
Feb 20, 2014, 10:38:50 PM2/20/14
to Hongwei Xi, ats-lan...@googlegroups.com

Or do you mean leaving out variable names? Yes, I see that is bad now.

Message has been deleted

gmhwxi

unread,
Feb 20, 2014, 10:41:09 PM2/20/14
to ats-lan...@googlegroups.com

If you annotate a function, please try to have types for arguments and result.

In the following case, there is no result type:

lam (x: int) => ...

In the following case, there is no argument type:

lam (x): int => ...


On Thursday, February 20, 2014 5:31:39 PM UTC-5, Brandon Barker wrote:
Reply all
Reply to author
Forward
0 new messages