Same linear variable in an argument

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no more
available

How to write above code in ATS2

Thanks

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brandon…@gmail.comOn Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker brandon...@gmail.comwrote:

Another thing that should work in principle is if we specify both vectors
are read-only, and while possible, I think this is a little more involved
in ATS (and I don’t think I’ve tried it).

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker <brandon...@gmail.com wrote:

I can’t think of a trivial (and safe) way to do it; one way might be to
use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions to
cast.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s chot...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brandon...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Thanks Brandon , I will take a look at it.On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker brandon...@gmail.comwrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker <brandon...@gmail.com wrote:

Another thing that should work in principle is if we specify both vectors
are read-only, and while possible, I think this is a little more involved
in ATS (and I don’t think I’ve tried it).

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker < brandon...@gmail.com> wrote:

I can’t think of a trivial (and safe) way to do it; one way might be to
use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions to
cast.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s chot...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brandon...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Yes , they are read only in my original code they are not modified by the
function.On Thu, Mar 13, 2014 at 8:49 PM, Brandon Barker brandon...@gmail.comwrote:

Another thing that should work in principle is if we specify both vectors
are read-only, and while possible, I think this is a little more involved
in ATS (and I don’t think I’ve tried it).

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker <brandon...@gmail.com wrote:

I can’t think of a trivial (and safe) way to do it; one way might be to
use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions to
cast.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s chot...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brandon...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Ah OK, I hadn’t realized they were removed. I’m not sure what is meant by
“at a higher level”.

Brandon Barker
brandon…@gmail.comOn Thu, Mar 13, 2014 at 12:13 PM, gmhwxi gmh...@gmail.com wrote:

I wrote plenty code involving read-only views.

However, it is very cumbersome to program with read-only views,
and the benefits from doing it seem rather limited. So there is no

longer built-in support for read-only views in ATS2.

However, at a higher-level, read-only views (and other data protection
concepts) can be very useful in system design.

On Thursday, March 13, 2014 11:26:26 AM UTC-4, chotu s wrote:

Thanks Brandon , I will take a look at it.

On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker brand...@gmail.comwrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker brand...@gmail.comwrote:

Another thing that should work in principle is if we specify both
vectors are read-only, and while possible, I think this is a little more
involved in ATS (and I don’t think I’ve tried it).

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker brand...@gmail.comwrote:

I can’t think of a trivial (and safe) way to do it; one way might be
to use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions
to cast.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s cho...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy
is costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker <brand...@gmail.com wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s cho...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is
no more available

How to write above code in ATS2

Thanks


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.
To post to this group, send email to ats-l...@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%
3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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.
To post to this group, send email to ats-l...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/
CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%
3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

One can define read-only views on one’s own.On Thursday, March 13, 2014 6:02:24 PM UTC-4, Brandon Barker wrote:

So in ATS2, I presume this wouldn’t be done with specialized views, but
rather read/write functions?
On Mar 13, 2014 12:31 PM, “gmhwxi” <gmh...@gmail.com <javascript:>> wrote:

Say you want to implement a read/write buffer shared by multiple threads.

On Thursday, March 13, 2014 12:18:24 PM UTC-4, Brandon Barker wrote:

Ah OK, I hadn’t realized they were removed. I’m not sure what is meant
by “at a higher level”.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 12:13 PM, gmhwxi gmh...@gmail.com wrote:

I wrote plenty code involving read-only views.

However, it is very cumbersome to program with read-only views,
and the benefits from doing it seem rather limited. So there is no

longer built-in support for read-only views in ATS2.

However, at a higher-level, read-only views (and other data protection
concepts) can be very useful in system design.

On Thursday, March 13, 2014 11:26:26 AM UTC-4, chotu s wrote:

Thanks Brandon , I will take a look at it.

On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker brand...@gmail.comwrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker < brand...@gmail.com> wrote:

Another thing that should work in principle is if we specify both
vectors are read-only, and while possible, I think this is a little more
involved in ATS (and I don’t think I’ve tried it).

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker < brand...@gmail.com> wrote:

I can’t think of a trivial (and safe) way to do it; one way might
be to use an option type for the vectors, and v2 is none, just access it as
v1 inside the function. I admit this is a rough idea and I have not tested
it.

An unsafe way might be to just pass pointers and use unsafe
functions to cast.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s cho...@gmail.comwrote:

I thought so . Is there any other way , without copy , say if
copy is costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brand...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s cho...@gmail.comwrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) :
void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which
is no more available

How to write above code in ATS2

Thanks


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.
To post to this group, send email to ats-l...@googlegroups.com
.

To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZD
hBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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.
To post to this group, send email to ats-l...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig
0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/a45c842a-9222-4b91-9d38-1640f5f5f176%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/a45c842a-9222-4b91-9d38-1640f5f5f176%40googlegroups.com?utm_medium=email&utm_source=footer
.

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon…@gmail.comOn Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no more
available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Say you want to implement a read/write buffer shared by multiple threads.On Thursday, March 13, 2014 12:18:24 PM UTC-4, Brandon Barker wrote:

Ah OK, I hadn’t realized they were removed. I’m not sure what is meant by
“at a higher level”.

Brandon Barker
brand...@gmail.com <javascript:>

On Thu, Mar 13, 2014 at 12:13 PM, gmhwxi <gmh...@gmail.com <javascript:>>wrote:

I wrote plenty code involving read-only views.

However, it is very cumbersome to program with read-only views,
and the benefits from doing it seem rather limited. So there is no

longer built-in support for read-only views in ATS2.

However, at a higher-level, read-only views (and other data protection
concepts) can be very useful in system design.

On Thursday, March 13, 2014 11:26:26 AM UTC-4, chotu s wrote:

Thanks Brandon , I will take a look at it.

On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker brand...@gmail.comwrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker brand...@gmail.comwrote:

Another thing that should work in principle is if we specify both
vectors are read-only, and while possible, I think this is a little more
involved in ATS (and I don’t think I’ve tried it).

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker <brand...@gmail.com wrote:

I can’t think of a trivial (and safe) way to do it; one way might
be to use an option type for the vectors, and v2 is none, just access it as
v1 inside the function. I admit this is a rough idea and I have not tested
it.

An unsafe way might be to just pass pointers and use unsafe functions
to cast.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s cho...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if
copy is costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brand...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s cho...@gmail.comwrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is
no more available

How to write above code in ATS2

Thanks


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.
To post to this group, send email to ats-l...@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/
CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%
3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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.
To post to this group, send email to ats-l...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/
CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%
3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

I thought so . Is there any other way , without copy , say if copy is
costly.On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker brandon...@gmail.comwrote:

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no more
available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

So in ATS2, I presume this wouldn’t be done with specialized views, but
rather read/write functions?On Mar 13, 2014 12:31 PM, “gmhwxi” gmh...@gmail.com wrote:

Say you want to implement a read/write buffer shared by multiple threads.

On Thursday, March 13, 2014 12:18:24 PM UTC-4, Brandon Barker wrote:

Ah OK, I hadn’t realized they were removed. I’m not sure what is meant by
“at a higher level”.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 12:13 PM, gmhwxi gmh...@gmail.com wrote:

I wrote plenty code involving read-only views.

However, it is very cumbersome to program with read-only views,
and the benefits from doing it seem rather limited. So there is no

longer built-in support for read-only views in ATS2.

However, at a higher-level, read-only views (and other data protection
concepts) can be very useful in system design.

On Thursday, March 13, 2014 11:26:26 AM UTC-4, chotu s wrote:

Thanks Brandon , I will take a look at it.

On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker brand...@gmail.comwrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker <brand...@gmail.com wrote:

Another thing that should work in principle is if we specify both
vectors are read-only, and while possible, I think this is a little more
involved in ATS (and I don’t think I’ve tried it).

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker < brand...@gmail.com> wrote:

I can’t think of a trivial (and safe) way to do it; one way might
be to use an option type for the vectors, and v2 is none, just access it as
v1 inside the function. I admit this is a rough idea and I have not tested
it.

An unsafe way might be to just pass pointers and use unsafe
functions to cast.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s cho...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if
copy is costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker < brand...@gmail.com> wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brand...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s cho...@gmail.comwrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is
no more available

How to write above code in ATS2

Thanks


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.
To post to this group, send email to ats-l...@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZD
hBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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.
To post to this group, send email to ats-l...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig
0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/a45c842a-9222-4b91-9d38-1640f5f5f176%40googlegroups.comhttps://groups.google.com/d/msgid/ats-lang-users/a45c842a-9222-4b91-9d38-1640f5f5f176%40googlegroups.com?utm_medium=email&utm_source=footer
.

I can’t think of a trivial (and safe) way to do it; one way might be to use
an option type for the vectors, and v2 is none, just access it as v1 inside
the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions to
cast.

Brandon Barker
brandon…@gmail.comOn Thu, Mar 13, 2014 at 10:46 AM, chotu s chot...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker brandon...@gmail.comwrote:

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

I wrote plenty code involving read-only views.

However, it is very cumbersome to program with read-only views,
and the benefits from doing it seem rather limited. So there is no
longer built-in support for read-only views in ATS2.

However, at a higher-level, read-only views (and other data protection
concepts) can be very useful in system design.On Thursday, March 13, 2014 11:26:26 AM UTC-4, chotu s wrote:

Thanks Brandon , I will take a look at it.

On Thu, Mar 13, 2014 at 8:54 PM, Brandon Barker <brand...@gmail.com<javascript:> wrote:

Here (I believe) is some not so light reading on the topic:
http://www.cs.bu.edu/~hwxi/academic/papers/ictac10.pdf
It does have a few examples.

Unfortunately I can’t recall if I’ve seen any other example code.

Brandon Barker
brand...@gmail.com <javascript:>

On Thu, Mar 13, 2014 at 11:19 AM, Brandon Barker <brand...@gmail.com<javascript:> wrote:

Another thing that should work in principle is if we specify both
vectors are read-only, and while possible, I think this is a little more
involved in ATS (and I don’t think I’ve tried it).

Brandon Barker
brand...@gmail.com <javascript:>

On Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker <brand...@gmail.com<javascript:> wrote:

I can’t think of a trivial (and safe) way to do it; one way might be to
use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions
to cast.

Brandon Barker
brand...@gmail.com <javascript:>

On Thu, Mar 13, 2014 at 10:46 AM, chotu s <cho...@gmail.com<javascript:> wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker <brand...@gmail.com<javascript:> wrote:

I think it makes sense that you can not pass (by value) the same
linear argument more than once in the same function call (you would
essentially have two “active views” for the same memory location); probably
what you want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brand...@gmail.com <javascript:>

On Thu, Mar 13, 2014 at 10:01 AM, chotu s <cho...@gmail.com<javascript:> wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Another thing that should work in principle is if we specify both vectors
are read-only, and while possible, I think this is a little more involved
in ATS (and I don’t think I’ve tried it).

Brandon Barker
brandon…@gmail.comOn Thu, Mar 13, 2014 at 11:15 AM, Brandon Barker brandon...@gmail.comwrote:

I can’t think of a trivial (and safe) way to do it; one way might be to
use an option type for the vectors, and v2 is none, just access it as v1
inside the function. I admit this is a rough idea and I have not tested it.

An unsafe way might be to just pass pointers and use unsafe functions to
cast.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:46 AM, chotu s chot...@gmail.com wrote:

I thought so . Is there any other way , without copy , say if copy is
costly.

On Thu, Mar 13, 2014 at 7:55 PM, Brandon Barker <brandon...@gmail.com wrote:

I think it makes sense that you can not pass (by value) the same linear
argument more than once in the same function call (you would essentially
have two “active views” for the same memory location); probably what you
want is to make an explicit copy when needed and pass it as well.

Brandon Barker
brandon...@gmail.com

On Thu, Mar 13, 2014 at 10:01 AM, chotu s chot...@gmail.com wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no
more available

How to write above code in ATS2

Thanks


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/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zLZDhBG02p%3D4d4hrYAMM1n1-x8CdyO07mGB_%3DLAVYYKg%40mail.gmail.com?utm_medium=email&utm_source=footer
.


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/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.comhttps://groups.google.com/d/msgid/ats-lang-users/CAORbNRoRig0dqP%3Ddr%3D6htPnHt4Ba2R7oNNis%3Dm8wHJSKciuPRQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Here is a way to do it. It is not type-safe but safe enough :slight_smile:

//
extern
fun{
a:t@ype
} some_fun{n:nat}
(!arrayptr (a, n), !arrayptr (a, n)): void
//
(* ****** ****** *)

implement
main0 ((void)) =
{
//
val A =
(arrayptr)$arrpsz{int}(0, 1)
//
val (fpf | A2) =
decode ($vcopyenv_vt(A))
val () = some_fun (A, A2)
prval ((void)) = fpf (A2)
//
val () = arrayptr_free (A)
//
} (* end of [main0] *)On Thursday, March 13, 2014 10:01:35 AM UTC-4, chotu s wrote:

Hello,

Can we pass same linear var in argument of a fun , for example :

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

extern
fun{a:t@ype}
some_fun{n:nat} (v1 : !arrayptr(a,n) , v2 : !arrayptr(a,n)) : void

implement main0 () = {
val v = arrayptr($arrpsz{int}(1,2,3,4,5))
val () = some_fun (v,v)
val () = arrayptr_free (v)
}

Above code does not compile , and complain for 2nd arg , which is no more
available

How to write above code in ATS2

Thanks