Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2135

Re: Method Call from inside a file.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: Method Call from inside a file.
Date Fri, 1 Apr 2011 17:00:20 -0500
Organization Service de news de lacave.net
Lines 31
Message-ID <b9bbd5905179d536fc41eb26e2d5eac8@ruby-forum.com> (permalink)
References <e4db35ea8bb31ebf053db829562ecabf@ruby-forum.com> <e0c5b4412cfe9be1068f352d3ba3824f@ruby-forum.com> <7823646f2514b0f079496a3719a70f72@ruby-forum.com> <dfe49bf2701da93ea247d28df645138a@ruby-forum.com>
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1301695280 73792 65.111.164.187 (1 Apr 2011 22:01:20 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Fri, 1 Apr 2011 22:01:20 +0000 (UTC)
In-Reply-To <dfe49bf2701da93ea247d28df645138a@ruby-forum.com>
X-Received-From This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway
X-Mail-Count 380778
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <b9bbd5905179d536fc41eb26e2d5eac8@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:2135

Show key headers only | View raw


Tridib Bandopadhyay wrote in post #990442:
>> I don't know what you mean by "acting like a library function".
>
> I mean to say that I am trying to write a function which will allow the
> users to free the allocated memory by themselves rather than doing it by
> Garbage Collection. So I need a syntax like that of C
>
> free(variable);

I believe you're writing C code for use by ruby. Ruby doesn't provide 
users with any free() method; users rely on garbage collection. So if 
you want to extend ruby in C, you need to make your code work with 
ruby's garbage collection.

A ruby user can *prevent* something from being garbage collected, if 
they want, just by holding a reference to it (e.g. in a global 
variable).

If you read 
http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html then 
you'll find whole sections on memory allocation and garbage collection. 
Look at Data_Make_Struct and Data_Wrap_Struct in particular. If you 
won't read the documentation, then I'm afraid you're on your own.

Of course, if you're writing C to be called from C (rather than from 
ruby) then you can have people call your own allocate and free routines. 
But this is not a forum about writing C programs.

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Method Call from inside a file. Tridib Bandopadhyay <tridib04@gmail.com> - 2011-04-01 10:44 -0500
  Re: Method Call from inside a file. Brian Candler <b.candler@pobox.com> - 2011-04-01 13:23 -0500
    Re: Method Call from inside a file. Tridib Bandopadhyay <tridib04@gmail.com> - 2011-04-01 13:33 -0500
      Re: Method Call from inside a file. Brian Candler <b.candler@pobox.com> - 2011-04-01 17:00 -0500

csiph-web