Call by const reference?

22 views
Skip to first unread message

Shea Levy

unread,
Sep 4, 2014, 3:04:43 PM9/4/14
to ats-lan...@googlegroups.com
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

gmhwxi

unread,
Sep 4, 2014, 4:04:06 PM9/4/14
to ats-lan...@googlegroups.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.

Shea Levy

unread,
Sep 4, 2014, 8:19:38 PM9/4/14
to ats-lan...@googlegroups.com
Would there be any way (possibly with unsafe features under the hood?)
to get a pointer to a value?
> --
> 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.

gmhwxi

unread,
Sep 4, 2014, 8:26:30 PM9/4/14
to ats-lan...@googlegroups.com

gmhwxi

unread,
Sep 4, 2014, 8:39:26 PM9/4/14
to ats-lan...@googlegroups.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 :)
Reply all
Reply to author
Forward
0 new messages