C's static equivalent

Hi!

Is there something similar to C’s static keyword?
I want a single function, which has to access and modify a permanent
variable. Any solution without bundling the function to a class?

Gergo

···


±[ Kontra, Gergelykgergely@mcl.hu PhD student Room IB113 ]---------+

http://www.mcl.hu/~kgergely “Olyan langesz vagyok, hogy |
Mobil:(+36 20) 356 9656 ICQ: 175564914 poroltoval kellene jarnom” |
±- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+

Is there something similar to C's static keyword?
I want a single function, which has to access and modify a permanent
variable. Any solution without bundling the function to a class?

Use a closure

Guy Decoux

Could you be more verbose? Eg. how to print out how many times a
function was called.

Gergo

···

On 0807, ts wrote:

Is there something similar to C’s static keyword?
I want a single function, which has to access and modify a permanent
variable. Any solution without bundling the function to a class?
Use a closure

±[ Kontra, Gergelykgergely@mcl.hu PhD student Room IB113 ]---------+
http://www.mcl.hu/~kgergely “Olyan langesz vagyok, hogy |
Mobil:(+36 20) 356 9656 ICQ: 175564914 poroltoval kellene jarnom” |
±- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+

Use a closure

Could you be more verbose? Eg. how to print out how many times a

in ruby, yes. in english, no :slight_smile:

function was called.

svg% cat b.rb
#!/usr/bin/ruby
def test1
   a = 10
   proc { a += 1; puts a }
end

class Object
   define_method(:tt, test1)
end

tt
tt

uu = test1
uu
uu
svg%

svg% b.rb
11
12
11
12
svg%

Guy Decoux

Woof. Thx. It works, but it’s a bit too obscure hacking for a damned
easy counter, isn’t it?

···

On 0807, ts wrote:

Use a closure
Could you be more verbose? Eg. how to print out how many times a
in ruby, yes. in english, no :slight_smile:
function was called.
svg% cat b.rb
#!/usr/bin/ruby
def test1
a = 10
proc { a += 1; puts a }
end

class Object
define_method(:tt, test1)
end

tt
tt

uu = test1
uu
uu
svg%

svg% b.rb
11
12
11
12
svg%
Guy Decoux


±[ Kontra, Gergelykgergely@mcl.hu PhD student Room IB113 ]---------+

http://www.mcl.hu/~kgergely “Olyan langesz vagyok, hogy |
Mobil:(+36 20) 356 9656 ICQ: 175564914 poroltoval kellene jarnom” |
±- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+

It would be worthwhile for all of us to
learn French in order to learn more of
your wisdom. :slight_smile:

Hal

···

----- Original Message -----
From: “ts” decoux@moulon.inra.fr
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org
Sent: Thursday, August 07, 2003 9:06 AM
Subject: Re: C’s static equivalent

Use a closure
Could you be more verbose? Eg. how to print out how many times a

in ruby, yes. in english, no :slight_smile:


Hal Fulton
hal9000@hypermetrics.com

Saluton!

  • Hal E. Fulton; 2003-08-07, 17:05 UTC:

It would be worthwhile for all of us to learn French in order to
learn more of your wisdom. :slight_smile:

Si on ne doit pas répondre en français :->
As long as we are not required to answer in french …

Gis,

Josef ‘Jupp’ Schugt

···


N’attribuez jamais à la malice ce que l’incompétence explique !
– Napoléon