From: David Brown <caml-list@davidb.org>
To: Mike Potanin <potanin@mccme.ru>
Cc: Brian Hurt <brian.hurt@qlogic.com>,
Blair Zajac <blair@orcaware.com>,
Caml Users Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Resource acquisition is initialization
Date: Fri, 13 Dec 2002 09:05:04 -0800 [thread overview]
Message-ID: <20021213170504.GA12278@opus.davidb.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0212131216320.24515-100000@mccme.ru>
On Fri, Dec 13, 2002 at 12:22:16PM +0300, Mike Potanin wrote:
> > char * foo(...) {
> > char buf[];
> > /* do something to fill buf */
> > return buf;
> > }
> >
> > This sounds like a wonderful way to introduce dangling pointer bugs in the
> > language.
> Cyclone language handle this problec staticaly (compile time). It no need
> GC use.
Numerous languages handle this kind of construct. Often, though, you
end up having to copy the result when you return. However, they
wouldn't handle it if the function was defined to return a pointer.
Instead, however, they let functions return larger objects (such as
arrays).
Usually they are implemented with a secondary stack to hold these
values.
I suspect, though, that the additional copying that ends up happening
with the technique ends up being as, or more, expensive than Ocaml's
garbage collector, especially if the data doesn't live long and doesn't
survive the young area.
Dave Brown
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-12-13 17:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-11 19:19 Blair Zajac
2002-12-11 19:55 ` Brian Hurt
2002-12-12 0:27 ` Chet Murthy
2002-12-12 7:56 ` Alessandro Baretta
2002-12-12 16:39 ` Brian Hurt
2002-12-13 9:22 ` Mike Potanin
2002-12-13 17:05 ` David Brown [this message]
2002-12-12 13:15 ` Xavier Leroy
2002-12-12 14:05 ` Dmitry Bely
2002-12-12 14:16 ` Xavier Leroy
2002-12-12 22:17 ` Quetzalcoatl Bradley
2002-12-12 23:59 ` Blair Zajac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021213170504.GA12278@opus.davidb.org \
--to=caml-list@davidb.org \
--cc=blair@orcaware.com \
--cc=brian.hurt@qlogic.com \
--cc=caml-list@inria.fr \
--cc=potanin@mccme.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox