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).
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.
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.
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).
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.
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.
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).
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.
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.
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).
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.
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.
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.
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”.
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).
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.
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.
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
.
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 :
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).
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.
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.
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.
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.
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”.
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).
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.
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.
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.
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.
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.
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:
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).
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.
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.
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.
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.