Templates and closures

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include "share/atspre_staload.hats"
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}

Can I also make closure function name visible inside a nested function i.e

implement{a}
fun (A,B,f) = {
implement somefun () = //make f visible here

}On Wed, Mar 12, 2014 at 10:31 AM, chotu s
chot...@gmail.com wrote:

Thanks , it now works properly. I’ll look at INV later.

In array.sats (development version , 0,0,07) , the array_foreach_clo is
define like this :

fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&a) -<clo,fe> void
) : void // end of [array_foreach_clo]

Should it not be defined like this :

extern
fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&(INV(a))) -<clo,fe> void
) : void // end of [array_foreach_clo]

only difference is in type of f .

On Tue, Mar 11, 2014 at 10:58 PM, gmhwxi gmh...@gmail.com wrote:

This involves a very subtle point in typechecking.

The code should work if you make the following change:

extern
fun{a:t@ype}
test2(f : &(&(INV(a)) - void ) : void

On Tuesday, March 11, 2014 12:10:17 PM UTC-4, chotu s wrote:

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}


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/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.com?utm_medium=email&utm_source=footer
.

I took a look. It should be:

fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n]) >> @[a][n]
, asz: size_t (n), f: &(&a >> _) -<clo,fe> void
) : void // end of [array_foreach_clo]

I have to say that this function and similar ones are kept mainly for the
purpose of
indicating how awkward the situation was in ATS1.

I suggest that you use array_foreach and array_foreach_env.On Wednesday, March 12, 2014 1:01:41 AM UTC-4, chotu s wrote:

Thanks , it now works properly. I’ll look at INV later.

In array.sats (development version , 0,0,07) , the array_foreach_clo is
define like this :

fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&a) -<clo,fe> void
) : void // end of [array_foreach_clo]

Should it not be defined like this :

extern
fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&(INV(a))) -<clo,fe> void
) : void // end of [array_foreach_clo]

only difference is in type of f .

On Tue, Mar 11, 2014 at 10:58 PM, gmhwxi <gmh...@gmail.com <javascript:>>wrote:

This involves a very subtle point in typechecking.

The code should work if you make the following change:

extern
fun{a:t@ype}
test2(f : &(&(INV(a)) - void ) : void

On Tuesday, March 11, 2014 12:10:17 PM UTC-4, chotu s wrote:

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com<javascript:>
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.com?utm_medium=email&utm_source=footer
.

This involves a very subtle point in typechecking.

The code should work if you make the following change:

extern
fun{a:t@ype}
test2(f : &(&(INV(a)) - void ) : voidOn Tuesday, March 11, 2014 12:10:17 PM UTC-4, chotu s wrote:

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}

Yes, you can.On Wednesday, March 12, 2014 1:09:43 AM UTC-4, chotu s wrote:

Can I also make closure function name visible inside a nested function i.e

implement{a}
fun (A,B,f) = {
implement somefun () = //make f visible here

}

On Wed, Mar 12, 2014 at 10:31 AM, chotu s <cho...@gmail.com <javascript:> wrote:

Thanks , it now works properly. I’ll look at INV later.

In array.sats (development version , 0,0,07) , the array_foreach_clo is
define like this :

fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&a) -<clo,fe> void
) : void // end of [array_foreach_clo]

Should it not be defined like this :

extern
fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&(INV(a))) -<clo,fe> void
) : void // end of [array_foreach_clo]

only difference is in type of f .

On Tue, Mar 11, 2014 at 10:58 PM, gmhwxi <gmh...@gmail.com <javascript:>>wrote:

This involves a very subtle point in typechecking.

The code should work if you make the following change:

extern
fun{a:t@ype}
test2(f : &(&(INV(a)) - void ) : void

On Tuesday, March 11, 2014 12:10:17 PM UTC-4, chotu s wrote:

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com<javascript:>
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.com?utm_medium=email&utm_source=footer
.

Thanks , it now works properly. I’ll look at INV later.

In array.sats (development version , 0,0,07) , the array_foreach_clo is
define like this :

fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&a) -<clo,fe> void
) : void // end of [array_foreach_clo]

Should it not be defined like this :

extern
fun{a:vt0p}
array_foreach_clo
{n:int}{fe:eff}
(
A: &(@[INV(a)][n])
, asz: size_t n
, f: &(&(INV(a))) -<clo,fe> void
) : void // end of [array_foreach_clo]

only difference is in type of f .On Tue, Mar 11, 2014 at 10:58 PM, gmhwxi gmh...@gmail.com wrote:

This involves a very subtle point in typechecking.

The code should work if you make the following change:

extern
fun{a:t@ype}
test2(f : &(&(INV(a)) - void ) : void

On Tuesday, March 11, 2014 12:10:17 PM UTC-4, chotu s wrote:

Hello ,

Any idea why test2 function does not work in this code :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
staload UN = “prelude/SATS/unsafe.sats”

extern
fun{a:t@ype}
test (f : &(&int) - void ) : void

implement{a}
test (f) = {}

extern
fun{a:t@ype}
test2(f : &(&a) - void ) : void

implement{a}
test2 (f) = {}

implement main0 () = {
var f = lam@ (x : &int) : void => {}
val () = test (f)
val () = test2 (f)
}


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/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/2c45b72d-c72c-44ac-8935-741850ae00b3%40googlegroups.com?utm_medium=email&utm_source=footer
.