Call by const reference?

Hi all,

Is there any way to declare a function call-by-reference but not allow
it to modify its arguments? Similarly, is there a way to pass a value
(not a variable) to such a function?

For my particular use case, I want to wrap the bind function, which
takes a const pointer to a struct sockaddr, and there’s no inherent
reason why a program shouldn’t be able to declare one as a val.

~Shea

Would there be any way (possibly with unsafe features under the hood?)
to get a pointer to a value?On Thu, Sep 04, 2014 at 01:04:06PM -0700, gmhwxi wrote:

Conceptually, this is easy to do:

absvtype RD (a:t@ype, l:addr) = ptr(l)

fun{a:t@ype} read{l:agz} (x: !RD (a, l)): a

Doing so means you need to write a lot of “administrative”
proof code.

On Thursday, September 4, 2014 3:04:43 PM UTC-4, Shea Levy wrote:

Hi all,

Is there any way to declare a function call-by-reference but not allow
it to modify its arguments? Similarly, is there a way to pass a value
(not a variable) to such a function?

For my particular use case, I want to wrap the bind function, which
takes a const pointer to a struct sockaddr, and there’s no inherent
reason why a program shouldn’t be able to declare one as a val.

~Shea


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 http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/421168e3-a2d8-486b-9c1d-eb1a5845499a%40googlegroups.com.

I guess it won’t hurt if I repeat myself one more time:

Learning how to use unsafe features in ATS is essential for the purpose
of practical
programming, that is, writing code that you and others can really use (and
also want to use).
The real world is far more complex than any type systems :)On Thursday, September 4, 2014 8:26:30 PM UTC-4, gmhwxi wrote:

See:

http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/x2107.html

On Thursday, September 4, 2014 8:19:38 PM UTC-4, Shea Levy wrote:

Would there be any way (possibly with unsafe features under the hood?)
to get a pointer to a value?

On Thu, Sep 04, 2014 at 01:04:06PM -0700, gmhwxi wrote:

Conceptually, this is easy to do:

absvtype RD (a:t@ype, l:addr) = ptr(l)

fun{a:t@ype} read{l:agz} (x: !RD (a, l)): a

Doing so means you need to write a lot of “administrative”
proof code.

On Thursday, September 4, 2014 3:04:43 PM UTC-4, Shea Levy wrote:

Hi all,

Is there any way to declare a function call-by-reference but not
allow
it to modify its arguments? Similarly, is there a way to pass a value
(not a variable) to such a function?

For my particular use case, I want to wrap the bind function, which
takes a const pointer to a struct sockaddr, and there’s no inherent
reason why a program shouldn’t be able to declare one as a val.

~Shea


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.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/421168e3-a2d8-486b-9c1d-eb1a5845499a%40googlegroups.com.

See:

http://www.ats-lang.org/DOCUMENT/INT2PROGINATS/HTML/x2107.htmlOn Thursday, September 4, 2014 8:19:38 PM UTC-4, Shea Levy wrote:

Would there be any way (possibly with unsafe features under the hood?)
to get a pointer to a value?

On Thu, Sep 04, 2014 at 01:04:06PM -0700, gmhwxi wrote:

Conceptually, this is easy to do:

absvtype RD (a:t@ype, l:addr) = ptr(l)

fun{a:t@ype} read{l:agz} (x: !RD (a, l)): a

Doing so means you need to write a lot of “administrative”
proof code.

On Thursday, September 4, 2014 3:04:43 PM UTC-4, Shea Levy wrote:

Hi all,

Is there any way to declare a function call-by-reference but not allow
it to modify its arguments? Similarly, is there a way to pass a value
(not a variable) to such a function?

For my particular use case, I want to wrap the bind function, which
takes a const pointer to a struct sockaddr, and there’s no inherent
reason why a program shouldn’t be able to declare one as a val.

~Shea


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:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/421168e3-a2d8-486b-9c1d-eb1a5845499a%40googlegroups.com.

Conceptually, this is easy to do:

absvtype RD (a:t@ype, l:addr) = ptr(l)

fun{a:t@ype} read{l:agz} (x: !RD (a, l)): a

Doing so means you need to write a lot of “administrative”
proof code.On Thursday, September 4, 2014 3:04:43 PM UTC-4, Shea Levy wrote:

Hi all,

Is there any way to declare a function call-by-reference but not allow
it to modify its arguments? Similarly, is there a way to pass a value
(not a variable) to such a function?

For my particular use case, I want to wrap the bind function, which
takes a const pointer to a struct sockaddr, and there’s no inherent
reason why a program shouldn’t be able to declare one as a val.

~Shea