implement main () = let
val a_foo = allocate_foo ()
in free_foo a_foo; 0 end
I’m not sure why that’s a change to dynamic semantics, since it only
affects functions that otherwise wouldn’t compile.
Well, this is just one convention. Say I do something like:
let
val a_foo = foo_acquire()
val () = …
val () = foo_release (a_foo)
in
// nothing
end
If ‘foo_release’ is not called, a_foo is freed automatically. I would rather
get a type-error message in this case. The point is that there are may be
more than one way to “free” a linear value.
It may sound a bit strange, but I, sometimes, see ATS as a form of
assembly. Programming
conventions should be pushed into meta-programming.On Saturday, September 13, 2014 6:27:28 PM UTC-4, Shea Levy wrote:
Hm, perhaps RAII is the wrong name for it. Consider the following code:
absviewt@ype foo = int
extern fn allocate_foo(): foo
extern fn free_foo(foo): void
implement main () = let
val a_foo = allocate_foo ()
in 0 end
Currently this won’t compile of course, as ‘a_foo’ is preserved. I’d
like a way to say something like “if a value of type foo is preserved at
the end of a scope where it needs to be consumed, sequence free_foo(val)
before the returned expression”, so that the above implementation of
main would be equivalent to
implement main () = let
val a_foo = allocate_foo ()
in free_foo a_foo; 0 end
I’m not sure why that’s a change to dynamic semantics, since it only
affects functions that otherwise wouldn’t compile.
~Shea
On Sat, Sep 13, 2014 at 01:23:43PM -0400, Hongwei Xi wrote:
Supporting RAII in a ATS-to-C compiler does not seem to be a good
design to me as doing it would require changing the dynamic semantics
of ATS. Also, linear types are a lot more flexible than RAII.
But it is conceivable for RAII to be some form of meta-programming
supported in a layer on top of ATS.
On Sat, Sep 13, 2014 at 11:11 AM, Shea Levy <sh...@shealevy.com <javascript:>> wrote:
That being said, does ATS have a way to do RAII/‘destructors’? Some
way
to say “if something of viewt@ype foo isn’t consumed at the end of
scope
and the type signature doesn’t allow it to be preserved, call function
bar on it”?
~Shea
On Fri, Sep 12, 2014 at 01:57:03PM -0400, Shea Levy wrote:
Ah, actually I don’t have to use views at all and can just provide a
function to get an @-view for garbage-collected values when needed.
Never mind!
~Shea
On Fri, Sep 12, 2014 at 01:53:07PM -0400, Shea Levy wrote:
Hi all,
Stack-allocated variables seem to be a special type of viewtype
where
the view is implicitly consumed at the end of the scope. Is it
possible
to define my own views like this , for example if I wanted to
implement
my own garbage collector?
~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/20140912175307.GC2251%40nixos.hsd1.nh.comcast.net
.
–
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/20140912175703.GA4120%40nixos.hsd1.nh.comcast.net
.
–
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/20140913151112.GA2275%40nixos.hsd1.nh.comcast.net
.
–
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/CAPPSPLpo%3DB1kdEaUK5o8-31qsaLEXVR0no1Uh2VOw%3DaC%3DVRjJA%40mail.gmail.com.