[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

top-level methods and constants

Xavier Noria

11/10/2007 5:10:00 PM

A couple of questions regarding the top-level environment of execution.

* The Pickaxe says on page 376 that top-level methods are defined as
private instance methods of Object, whereas Ruby for Rails says on
page 203 they are private instance methods of the Kernel module. Which
one is correct?

* Which is the actual container of a top-level constant?

-- fxn


12 Answers

David A. Black

11/10/2007 5:25:00 PM

0

Hi --

On Sun, 11 Nov 2007, Xavier Noria wrote:

> A couple of questions regarding the top-level environment of execution.
>
> * The Pickaxe says on page 376 that top-level methods are defined as private
> instance methods of Object, whereas Ruby for Rails says on page 203 they are
> private instance methods of the Kernel module. Which one is correct?

The Pickaxe is right. I believe it got fixed in later printings of
R4R, though. I can't remember what led to the original mistake -- I
think I misinterpreted some method-list output I was getting while
examining it all in irb, or something.

> * Which is the actual container of a top-level constant?

You may not want me to answer :-) But I do believe it's Object.

ruby -ve "A=1; Object::A; Kernel::A"
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]
-e:1: uninitialized constant Kernel::A (NameError)

(plus a couple of void context warnings which don't matter)


David

--
Upcoming training by David A. Black/Ruby Power and Light, LLC:
* Advancing With Rails, Berlin, Germany, November 19-22
* Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.r... for details!

Rick DeNatale

11/10/2007 5:29:00 PM

0

On Nov 10, 2007 12:10 PM, Xavier Noria <fxn@hashref.com> wrote:
> A couple of questions regarding the top-level environment of execution.
>
> * The Pickaxe says on page 376 that top-level methods are defined as
> private instance methods of Object, whereas Ruby for Rails says on
> page 203 they are private instance methods of the Kernel module. Which
> one is correct?

Looks like the pickaxe:

def foo
end

self.private_methods.include?("foo") # => true
Object.private_instance_methods(false).include?("foo") # => true
Kernel.private_instance_methods(false).include?("foo") # => false

Note though that in irb top level methods are public:
irb(main):001:0> def foo
irb(main):002:1> end
=> nil
irb(main):003:0>
irb(main):004:0* self.private_methods.include?("foo")
=> false
irb(main):005:0> Object.private_instance_methods(false).include?("foo")
=> false
irb(main):006:0> Kernel.private_instance_methods(false).include?("foo")
=> false
irb(main):007:0> Object.instance_methods(false).include?("foo")
=> true
irb(main):008:0>

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

Ian J. Ball

8/1/2013 8:32:00 PM

0

In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
anim8rFSK <anim8rfsk@cox.net> wrote:

> In article
> <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
>
> > Arrow (rerun) - The rerun in which James Callis plays "The Dodger", and
> > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > FTR, this was the episode in which the put Felicity in a dress, but
> > they never showed her legs, so I still don't know if Emily Bett Rickards
> > has the terrible legs that Fred claims she does, or not... :/
>
> Well, it's just that they're very very very short.

I just want to get a look at this chyck's legs so I can decide for
myself!!

--
"Surf-crazed aliens... Of course." - Amber, "Alien Surf Girls",
Episode #1.1, "Wipeout".
Wait a minute... "Of course"?! "*Of course*"?!! Did I miss a step here??!!

Anim8rFSK

8/1/2013 10:35:00 PM

0

In article
<ijball-NO_SPAM-2ADE87.13313501082013@news.eternal-september.org>,
"Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:

> In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
> anim8rFSK <anim8rfsk@cox.net> wrote:
>
> > In article
> > <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> >
> > > Arrow (rerun) - The rerun in which James Callis plays "The Dodger", and
> > > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > > FTR, this was the episode in which the put Felicity in a dress, but
> > > they never showed her legs, so I still don't know if Emily Bett Rickards
> > > has the terrible legs that Fred claims she does, or not... :/
> >
> > Well, it's just that they're very very very short.
>
> I just want to get a look at this chyck's legs so I can decide for
> myself!!

it's not exactly a hard google :P

http://25.media.tumblr.com/029608985894e4c18a6fe431ec1d93d1/tum...
zdV71qlp7rso1_500.png

http://images.starpulse.com/pictures/2013/05/18/previews/Emily%...
ickards-JTM-064295.jpg

https://si0.twimg.com/profile_images/378800000162218283/abd3921...
1fefcdb14e6d7d3.jpeg

http://www.gettyimages.in/detail/news-photo/actress-emily-bett-...
eaves-her-midtown-manhattan-news-photo/168925290

http://www.gettyimages.in/detail/news-photo/emily-bett-rickards...
t-the-television-critic-news-photo/175057364

http://www.gettyimages.in/detail/news-photo/emily-bett-rickards...
t-the-television-critic-news-photo/175057362

http://images6.fanpop.com/image/photos/34500000/Stephen-Amell-a...
ett-Rickard-CW-Promo-2013-arrow-cw-34534298-500-500.png

http://24.media.tumblr.com/aee3be48d5b641cf9d160607820e5fdd/tum...
TkVi1s8kwr6o1_500.png

http://www.gettyimages.com/detail/news-photo/actress-emily-bett...
attends-the-cw-networks-new-news-photo/168889877

http://www4.pictures.zimbio.com/gi/Emily+bett+Rickards+CW+CBS+S...
13+Summer+dkaBXHipTr9l.jpg
(looks like she has tattoo disfigured feet too)

http://www.hollywoodreporter.com/sites/default/files/imagecache...
_carousel/2013/07/arrow_a.jpg

http://www.gettyimages.in/detail/news-photo/actress-emily-bett-...
rrives-at-the-cw-cbs-and-news-photo/175029570

http://starlingcity.com/wp-content/uploads/sites/3/2013/07/wUpf...
0.jpg

--
Wait - are you saying that ClodReamer was wrong, or lying?

David Barnett

8/2/2013 3:26:00 AM

0

In article <ijball-NO_SPAM-5A1BE3.09292901082013
@news.eternal-september.org>, ijball-NO_SPAM@mac.invalid
says...
>
> In article <ktdlbu$eej$1@dont-email.me>,
> Ubiquitous <weberm@polaris.net> wrote:
>
> > What did you watch?
>
> Covert Affairs (recorded) - "Into The White". A silly outing in which
> Annie tries to bring Arthur's bastard son Teo "in from the cold" but is
> confused about whether Teo's "flipped" or not, and in which Joan
> "cleans" Annie's crime scene back in D.C. and lucks out with fresh dirt
> she can use for her confirmation hearings for D.C.I.
> This season is proving to not be very good, mostly because the main
> continuing storyline is really uninteresting.
<snip>

I haven't watched this episode yet.
I intend to do so this afternoon, and I don't mind the
spoilers above - it is to me more like the usual sort of
blurb one can read before watching a show.

Anyway, the point of my post is agreeing with you re this
being a disappointing season.
--
David Barnett

David Barnett

8/2/2013 3:34:00 AM

0

In article <anim8rfsk-BB002C.11233301082013
@news.easynews.com>, anim8rfsk@cox.net says...

<snips>

> In article
> <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> >
> > Covert Affairs (recorded) - "Into The White". the main
> > continuing storyline is really uninteresting.
>
> And Auggie and Annie aren't interesting, and pregnant Joan isn't
> interesting, and Arthur on the run isn't interesting ...

I find Jai's father interesting.
I keep looking to see if he ever keeps his head on
straight.

--
David Barnett

Ian J. Ball

8/2/2013 3:55:00 PM

0

In article <anim8rfsk-3D1890.15350401082013@news.easynews.com>,
anim8rFSK <anim8rfsk@cox.net> wrote:

> In article
> <ijball-NO_SPAM-2ADE87.13313501082013@news.eternal-september.org>,
> "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
> > anim8rFSK <anim8rfsk@cox.net> wrote:
> > > In article
> > > <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > >
> > > > Arrow (rerun) - The rerun in which James Callis plays "The Dodger", and
> > > > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > > > FTR, this was the episode in which the put Felicity in a dress, but
> > > > they never showed her legs, so I still don't know if Emily Bett
> > > > Rickards
> > > > has the terrible legs that Fred claims she does, or not... :/
> > >
> > > Well, it's just that they're very very very short.
> >
> > I just want to get a look at this chyck's legs so I can decide for
> > myself!!
>
> it's not exactly a hard google :P
>
> [snip image links]

Ironically, none of those show her "full legs", so I still can't tell if
there's a "problem" or not... :p

--
"Surf-crazed aliens... Of course." - Amber, "Alien Surf Girls",
Episode #1.1, "Wipeout".
Wait a minute... "Of course"?! "*Of course*"?!! Did I miss a step here??!!

Anim8rFSK

8/2/2013 6:46:00 PM

0

In article
<ijball-NO_SPAM-08714F.08544902082013@news.eternal-september.org>,
"Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:

> In article <anim8rfsk-3D1890.15350401082013@news.easynews.com>,
> anim8rFSK <anim8rfsk@cox.net> wrote:
>
> > In article
> > <ijball-NO_SPAM-2ADE87.13313501082013@news.eternal-september.org>,
> > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
> > > anim8rFSK <anim8rfsk@cox.net> wrote:
> > > > In article
> > > > <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> > > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > >
> > > > > Arrow (rerun) - The rerun in which James Callis plays "The Dodger",
> > > > > and
> > > > > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > > > > FTR, this was the episode in which the put Felicity in a dress,
> > > > > but
> > > > > they never showed her legs, so I still don't know if Emily Bett
> > > > > Rickards
> > > > > has the terrible legs that Fred claims she does, or not... :/
> > > >
> > > > Well, it's just that they're very very very short.
> > >
> > > I just want to get a look at this chyck's legs so I can decide for
> > > myself!!
> >
> > it's not exactly a hard google :P
> >
> > [snip image links]
>
> Ironically, none of those show her "full legs", so I still can't tell if
> there's a "problem" or not... :p

I think you have your answer right there.

--
Wait - are you saying that ClodReamer was wrong, or lying?

Jim G.

8/2/2013 9:05:00 PM

0

anim8rFSK sent the following on Fri, 02 Aug 2013 11:45:52 -0700:
> In article
> <ijball-NO_SPAM-08714F.08544902082013@news.eternal-september.org>,
> "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
>
> > In article <anim8rfsk-3D1890.15350401082013@news.easynews.com>,
> > anim8rFSK <anim8rfsk@cox.net> wrote:
> >
> > > In article
> > > <ijball-NO_SPAM-2ADE87.13313501082013@news.eternal-september.org>,
> > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > > In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
> > > > anim8rFSK <anim8rfsk@cox.net> wrote:
> > > > > In article
> > > > > <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> > > > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > > >
> > > > > > Arrow (rerun) - The rerun in which James Callis plays "The Dodger",
> > > > > > and
> > > > > > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > > > > > FTR, this was the episode in which the put Felicity in a dress,
> > > > > > but
> > > > > > they never showed her legs, so I still don't know if Emily Bett
> > > > > > Rickards
> > > > > > has the terrible legs that Fred claims she does, or not... :/
> > > > >
> > > > > Well, it's just that they're very very very short.
> > > >
> > > > I just want to get a look at this chyck's legs so I can decide for
> > > > myself!!
> > >
> > > it's not exactly a hard google :P
> > >
> > > [snip image links]
> >
> > Ironically, none of those show her "full legs", so I still can't tell if
> > there's a "problem" or not... :p
>
> I think you have your answer right there.

I keep telling you guys that you *are* seeing her full legs in those
shots. They're just really, really stubby. :)

--
Jim G. | A fan of the good and the bad, but not the mediocre
"Dang it. That was my best Dirty Harry. He might just be an idiot." -- Jason Stackhouse, TRUE BLOOD

Anim8rFSK

8/2/2013 10:26:00 PM

0

In article <sn7ov8le1ie9d880hmt0kg84bno5qgpu61@4ax.com>,
Jim G. <jimgysin@geemail.com.invalid> wrote:

> anim8rFSK sent the following on Fri, 02 Aug 2013 11:45:52 -0700:
> > In article
> > <ijball-NO_SPAM-08714F.08544902082013@news.eternal-september.org>,
> > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> >
> > > In article <anim8rfsk-3D1890.15350401082013@news.easynews.com>,
> > > anim8rFSK <anim8rfsk@cox.net> wrote:
> > >
> > > > In article
> > > > <ijball-NO_SPAM-2ADE87.13313501082013@news.eternal-september.org>,
> > > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > > > In article <anim8rfsk-BB002C.11233301082013@news.easynews.com>,
> > > > > anim8rFSK <anim8rfsk@cox.net> wrote:
> > > > > > In article
> > > > > > <ijball-NO_SPAM-5A1BE3.09292901082013@news.eternal-september.org>,
> > > > > > "Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:
> > > > > >
> > > > > > > Arrow (rerun) - The rerun in which James Callis plays "The
> > > > > > > Dodger",
> > > > > > > and
> > > > > > > hooks up an IED to the lovely Felicity Smoak's [snicker!] neck.
> > > > > > > FTR, this was the episode in which the put Felicity in a
> > > > > > > dress,
> > > > > > > but
> > > > > > > they never showed her legs, so I still don't know if Emily Bett
> > > > > > > Rickards
> > > > > > > has the terrible legs that Fred claims she does, or not... :/
> > > > > >
> > > > > > Well, it's just that they're very very very short.
> > > > >
> > > > > I just want to get a look at this chyck's legs so I can decide for
> > > > > myself!!
> > > >
> > > > it's not exactly a hard google :P
> > > >
> > > > [snip image links]
> > >
> > > Ironically, none of those show her "full legs", so I still can't tell if
> > > there's a "problem" or not... :p
> >
> > I think you have your answer right there.
>
> I keep telling you guys that you *are* seeing her full legs in those
> shots. They're just really, really stubby. :)

With self mutilated feet hanging at the bottoms, not quite reaching the
ground.

--
Wait - are you saying that ClodReamer was wrong, or lying?