How to avoid inheriting Object?

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

Thanks

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

              matz.

···

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. 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

···

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?

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

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.

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/BlankSlate.rdoc\.

···

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.

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"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)

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.

···

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.

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

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.

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.

···

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/BlankSlate.rdoc\.

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

T.

···

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.

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.

···

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.

Hi,

···

In message "Re: How to avoid inheriting Object?" on Thu, 25 Nov 2004 12:19:47 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:

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

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

MyClass < Object < ObjectShell

I don't think I understand what you mean. What does ObjectShell mean?

              matz.

Or have the ability to uninclude a module...

Cheers

Dave

···

On Nov 24, 2004, at 21:19, trans. (T. Onoma) wrote:

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

  MyClass < Object < ObjectShell

I'm guessing that ObjectShell is the ultimate blank slate. It is the root of
the object system and only provides the absolute minimum number of methods
(probably only __id__ and __send__). All normal objects inherit from Object
as they do now, but special objects that don't want all the Object stuff by
default (e.g. things like Builder or dynamic proxy objects) could inherit
from ObjectShell.

···

On Wednesday 24 November 2004 10:32 pm, Yukihiro Matsumoto wrote:

    on Thu, 25 Nov 2004 12:19:47 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:
>I think that's good. But you can have "kernelless" object without loosing
>"single class tree":
>
> MyClass < Object < ObjectShell

I don't think I understand what you mean. What does ObjectShell mean?

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"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)

I'd *love* to have that. Then I could make Transaction::Simple's
block-form very clean (e.g., it wouldn't leave traces of itself in
objects after the transaction block is complete).

-austin

···

On Thu, 25 Nov 2004 13:49:26 +0900, Dave Thomas <pragdave@gmail.com> wrote:

On Nov 24, 2004, at 21:19, trans. (T. Onoma) wrote:
> I think that's good. But you can have "kernelless" object without
> loosing
> "single class tree":
> MyClass < Object < ObjectShell
Or have the ability to uninclude a module...

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

This is right.

I do not know if there is a saying in Japanese like we have in English: "shell
of a __thing__", which means that __thing__ is a such on the outside, but not
so inside --hence "shell of an Object" -> ObjectShell. Of course a better
name might just be ObjectClass.

I concur with Jim that it would only have "__meth__" style methods. In
addition to the two mentioned above I might add #__class__ and a
__method_missing__ callback.

It would be useful for OpenStruct, and maybe DRb too.

T.

P.S. Maybe also (alhtough I'm not at all sure about this) the class should not
be reopenable. ?

···

On Wednesday 24 November 2004 11:40 pm, Jim Weirich wrote:

On Wednesday 24 November 2004 10:32 pm, Yukihiro Matsumoto wrote:
> on Thu, 25 Nov 2004 12:19:47 +0900, "trans. (T. Onoma)" > > <transami@runbox.com> writes:
> >I think that's good. But you can have "kernelless" object without
> > loosing "single class tree":
> >
> > MyClass < Object < ObjectShell
>
> I don't think I understand what you mean. What does ObjectShell mean?

I'm guessing that ObjectShell is the ultimate blank slate. It is the root
of the object system and only provides the absolute minimum number of
methods (probably only __id__ and __send__). All normal objects inherit
from Object as they do now, but special objects that don't want all the
Object stuff by default (e.g. things like Builder or dynamic proxy objects)
could inherit from ObjectShell.

I'd *love* to have that. Then I could make Transaction::Simple's
block-form very clean (e.g., it wouldn't leave traces of itself in
objects after the transaction block is complete).

yes, and then just uninclude Kernel from a class and all classes will lost
it :slight_smile:

Guy Decoux