[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How to avoid inheriting Object?

Its Me

11/24/2004 1:24:00 AM

How do I create a class that does not inherit from Object?

Thanks


16 Answers

Yukihiro Matsumoto

11/24/2004 3:15:00 AM

0


In message "Re: How to avoid inheriting Object?"
on Wed, 24 Nov 2004 10:29:09 +0900, "itsme213" <itsme213@hotmail.com> writes:

|How do I create a class that does not inherit from Object?

You can't. But if you describe what you really want, it might be
possible by other way.

matz.


Austin Ziegler

11/24/2004 3:18:00 AM

0

On Wed, 24 Nov 2004 10:29:09 +0900, itsme213 <itsme213@hotmail.com> wrote:
> How do I create a class that does not inherit from Object?

You can't. All objects inherit from Object.

If, however, you want a bare class (e.g., nothing except __send__ and
__id__), then there are ways to do that. Look at the evilruby project
and I think that Jim Weirich has said stuff about this on his
onestepback blog.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Its Me

11/24/2004 3:23:00 AM

0

I am creating classes to model a domain and want to start with a 'blank
slate' i.e. without all the methods defined on Object. At least I think
that's what I want.


"Yukihiro Matsumoto" <matz@ruby-lang.org> wrote in message
news:1101266071.062555.32385.nullmailer@x31.priv.netlab.jp...
>
> In message "Re: How to avoid inheriting Object?"
> on Wed, 24 Nov 2004 10:29:09 +0900, "itsme213" <itsme213@hotmail.com>
writes:
>
> |How do I create a class that does not inherit from Object?
>
> You can't. But if you describe what you really want, it might be
> possible by other way.
>
> matz.
>
>


Yukihiro Matsumoto

11/24/2004 3:34:00 AM

0

Hi,

In message "Re: How to avoid inheriting Object?"
on Wed, 24 Nov 2004 12:28:01 +0900, "itsme213" <itsme213@hotmail.com> writes:
|
|I am creating classes to model a domain and want to start with a 'blank
|slate' i.e. without all the methods defined on Object. At least I think
|that's what I want.

Undefining methods may accomplish what you want. But I think you have
to keep "some" methods such as __id__, __send__, etc.

matz.


Jim Weirich

11/24/2004 5:55:00 AM

0

On Tuesday 23 November 2004 10:18 pm, Austin Ziegler wrote:
> On Wed, 24 Nov 2004 10:29:09 +0900, itsme213 <itsme213@hotmail.com> wrote:
> > How do I create a class that does not inherit from Object?
>
> You can't. All objects inherit from Object.
>
> If, however, you want a bare class (e.g., nothing except __send__ and
> __id__), then there are ways to do that. Look at the evilruby project
> and I think that Jim Weirich has said stuff about this on his
> onestepback blog.

Builder 1.2.2 is available as a gem and includes the most recent version of
BlankSlate. Although conceptually simple, it turns out there are a few
gotchas when writing a good BlankSlate object. The version in builder is
addresses all the issues I am aware of.

The blog entry describing the initial BlankSlate is at
http://onest.../index.cgi/Tech/Ruby/Blank....

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)


Mauricio Fernández

11/24/2004 10:38:00 AM

0

On Wed, Nov 24, 2004 at 12:18:24PM +0900, Austin Ziegler wrote:
> On Wed, 24 Nov 2004 10:29:09 +0900, itsme213 <itsme213@hotmail.com> wrote:
> > How do I create a class that does not inherit from Object?
>
> You can't. All objects inherit from Object.
>
> If, however, you want a bare class (e.g., nothing except __send__ and
> __id__), then there are ways to do that. Look at the evilruby project
> and I think that Jim Weirich has said stuff about this on his
> onestepback blog.

Actually, evil.rb does provide objects which do not inherit from Object.
In fact, you'd normally have to add __send__ and __id__ yourself.
BlankSlate just 'undefines' the instance methods, but it doesn't do
anything about singleton methods of the class, for instance.

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyar...


T. Onoma

11/24/2004 12:13:00 PM

0

On Wednesday 24 November 2004 12:54 am, Jim Weirich wrote:
| On Tuesday 23 November 2004 10:18 pm, Austin Ziegler wrote:
| > On Wed, 24 Nov 2004 10:29:09 +0900, itsme213 <itsme213@hotmail.com> wrote:
| > > How do I create a class that does not inherit from Object?
| >
| > You can't. All objects inherit from Object.
| >
| > If, however, you want a bare class (e.g., nothing except __send__ and
| > __id__), then there are ways to do that. Look at the evilruby project
| > and I think that Jim Weirich has said stuff about this on his
| > onestepback blog.
|
| Builder 1.2.2 is available as a gem and includes the most recent version of
| BlankSlate. Although conceptually simple, it turns out there are a few
| gotchas when writing a good BlankSlate object. The version in builder is
| addresses all the issues I am aware of.
|
| The blog entry describing the initial BlankSlate is at
| http://onestepback.org/index.cgi/Tech/Ruby/Blank....

Nice work Jim. Builder looks quite useful and might prove useful to those
interested in the YAML vs. Marshalling thread --but then how would they
really guess that?

Might I suggest changing the name to something a little more descriptive
--like XMLBuilder. Just Builder is rather general and undescriptive. With a
more specific name I think you'll pick-up more hits. The GEM description BTW
didn't improve matters much either.

builder (1.2.2)
Builders for MarkUp.

If it wasn't for this BlankSlate post, I would never have known what this was
for.

T.


T. Onoma

11/24/2004 12:30:00 PM

0

On Wednesday 24 November 2004 05:37 am, Mauricio Fernández wrote:
| On Wed, Nov 24, 2004 at 12:18:24PM +0900, Austin Ziegler wrote:
| > On Wed, 24 Nov 2004 10:29:09 +0900, itsme213 <itsme213@hotmail.com> wrote:
| > > How do I create a class that does not inherit from Object?
| >
| > You can't. All objects inherit from Object.
| >
| > If, however, you want a bare class (e.g., nothing except __send__ and
| > __id__), then there are ways to do that. Look at the evilruby project
| > and I think that Jim Weirich has said stuff about this on his
| > onestepback blog.
|
| Actually, evil.rb does provide objects which do not inherit from Object.
| In fact, you'd normally have to add __send__ and __id__ yourself.
| BlankSlate just 'undefines' the instance methods, but it doesn't do
| anything about singleton methods of the class, for instance.

Might we expect a real "kernelless" object in Ruby 2 ?

T.



Yukihiro Matsumoto

11/24/2004 11:29:00 PM

0

Hi,

In message "Re: How to avoid inheriting Object?"
on Wed, 24 Nov 2004 21:29:57 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:

|Might we expect a real "kernelless" object in Ruby 2 ?

No. We are not going to abandon "single class tree" model.

matz.


T. Onoma

11/25/2004 3:20:00 AM

0

On Wednesday 24 November 2004 06:28 pm, Yukihiro Matsumoto wrote:
| Hi,
|
| In message "Re: How to avoid inheriting Object?"
|
| on Wed, 24 Nov 2004 21:29:57 +0900, "trans. (T. Onoma)"
<transami@runbox.com> writes:
| |Might we expect a real "kernelless" object in Ruby 2 ?
|
| No. We are not going to abandon "single class tree" model.
|
| matz.

I think that's good. But you can have "kernelless" object without loosing
"single class tree":

MyClass < Object < ObjectShell

T.