OT: Traits


(Daniel Berger) #1

All,

I came across this article recently:
http://www.cse.ogi.edu/~black/publications/TR_CSE_02-012.pdf

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

Regards,

Dan

PS - Sorry if this is a double post. Emails sent from my home and
work account don’t appear to be making it to the list. This was
posted via Google Groups.


(Yukihiro Matsumoto) #2

Hi,

···

In message “OT: Traits” on 04/02/14, Daniel Berger djberg96@hotmail.com writes:

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

“module” in Ruby and “trait” are very similar idea.

						matz.

#3

In article 6e613a32.0402130813.407a4e35@posting.google.com,

All,

I came across this article recently:
http://www.cse.ogi.edu/~black/publications/TR_CSE_02-012.pdf

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

OGI is in my neighborhood. :slight_smile:

I found this interesting quote on the first page:

“Despite the passage of nearly twenty years, neither multiple inheritance
nor mixins have acheived wide acceptance”

Well, I can see why multiple inheritance has fallen out of favor, but I
use mixins all the time.

Phil

···

Daniel Berger djberg96@hotmail.com wrote:


(Laurent Julliard) #4

just found this:
http://homepages.ihug.com.au/~naseby/33.html
I wonder why the author did not post a message here, I hope he does’nt
bother if I do :slight_smile:

PS
I’d like to remind you: if you have a weblog please subscribe
artima.com’s ruby buzz, it’s cool :slight_smile:

···

il 13 Feb 2004 08:13:07 -0800, djberg96@hotmail.com (Daniel Berger) ha scritto::

All,

I came across this article recently:
http://www.cse.ogi.edu/~black/publications/TR_CSE_02-012.pdf

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?


(David Naseby) #5

I’ve just done a writeup of Traits in Ruby on my blog
(http://homepages.ihug.com.au/~naseby/33.html). I think, in summary, that
traits are a solution to a problem that may cause more problems, if
implemented in a language without a good browsing IDE (ie, pretty much
anything except Smalltak). I like the finer grained composition in theory
for its flexibility, and I like the level of library support that a traits
implementation can provide over and above straight Ruby modules. But its
probably not worth the trouble…

David
http://homepages.ihug.com.au/~naseby/

···

-----Original Message-----
From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org]

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

“module” in Ruby and “trait” are very similar idea.


(Daniel Berger) #6

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message news:1076736977.263683.27564.nullmailer@picachu.netlab.jp

Hi,

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

“module” in Ruby and “trait” are very similar idea.

  					matz.

Yes, I thought so, too. Their argument against mixins boiled down to
"What if you have identical methods in two different modules that you
wish to ‘include’?". But, so far that just hasn’t happened in my
personal experience.

Dan

···

In message “OT: Traits” > on 04/02/14, Daniel Berger djberg96@hotmail.com writes:


(Daniel Berger) #7

gabriele renzi surrender_it@remove.yahoo.it wrote in message news:0qgu20lvm2r0gtr0qnc5pf8c672ef7pr35@4ax.com

il 13 Feb 2004 08:13:07 -0800, djberg96@hotmail.com (Daniel Berger) ha
scritto::

All,

I came across this article recently:
http://www.cse.ogi.edu/~black/publications/TR_CSE_02-012.pdf

Since I haven’t seen a full discussion on the topic, I thought I would
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

just found this:
http://homepages.ihug.com.au/~naseby/33.html
I wonder why the author did not post a message here, I hope he does’nt
bother if I do :slight_smile:

Actually, he did post to the mailing list (I can see it in the
archive) but it didn’t show up in the newsgroup for some reason. Odd.

Dan


(Robert) #8

“Daniel Berger” djberg96@hotmail.com schrieb im Newsbeitrag
news:6e613a32.0402150859.2a73ae45@posting.google.com

gabriele renzi surrender_it@remove.yahoo.it wrote in message
news:0qgu20lvm2r0gtr0qnc5pf8c672ef7pr35@4ax.com

il 13 Feb 2004 08:13:07 -0800, djberg96@hotmail.com (Daniel Berger) ha
scritto::

All,

I came across this article recently:
http://www.cse.ogi.edu/~black/publications/TR_CSE_02-012.pdf

Since I haven’t seen a full discussion on the topic, I thought I
would

see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

just found this:
http://homepages.ihug.com.au/~naseby/33.html
I wonder why the author did not post a message here, I hope he does’nt
bother if I do :slight_smile:

Actually, he did post to the mailing list (I can see it in the
archive) but it didn’t show up in the newsgroup for some reason. Odd.

Dan

This explains my impression that message traffic has dropped since two or
three weeks. (I’m reading news only.)

Does someone take action on this already? Thx!

Regards

robert

(Robert) #9

“Daniel Berger” djberg96@hotmail.com schrieb im Newsbeitrag
news:6e613a32.0402140823.6e549b24@posting.google.com

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message
news:1076736977.263683.27564.nullmailer@picachu.netlab.jp

Hi,

Since I haven’t seen a full discussion on the topic, I thought I
would

see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

“module” in Ruby and “trait” are very similar idea.

matz.

Yes, I thought so, too. Their argument against mixins boiled down to
"What if you have identical methods in two different modules that you
wish to ‘include’?". But, so far that just hasn’t happened in my
personal experience.

The problem that I see is with using Modules is when traits have to be
exchanged during the life time of an instance. At least I didn’t manage
to include a Module and de-include if afterwards. Or does simply
"overriding" by including another module with similar methods solve the
problem?

Kind regards

robert
···

In message “OT: Traits” > > on 04/02/14, Daniel Berger djberg96@hotmail.com writes:


(David A. Black) #10

Hi –

···

On Mon, 16 Feb 2004, Robert Klemme wrote:

This explains my impression that message traffic has dropped since two or
three weeks. (I’m reading news only.)

Yeah, according to Google I’ve posted 4 msgs in the past month. In
fact it’s more like 15-20.

David


David A. Black
dblack@wobblini.net


#11

“Robert Klemme” bob.news@gmx.net wrote in message news:c0q8nb$19imk0$1@ID-52924.news.uni-berlin.de

“Daniel Berger” djberg96@hotmail.com schrieb im Newsbeitrag
news:6e613a32.0402140823.6e549b24@posting.google.com

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message
news:1076736977.263683.27564.nullmailer@picachu.netlab.jp

Hi,

Since I haven’t seen a full discussion on the topic, I thought I
would

see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?

“module” in Ruby and “trait” are very similar idea.

matz.

Yes, I thought so, too. Their argument against mixins boiled down to
"What if you have identical methods in two different modules that you
wish to ‘include’?". But, so far that just hasn’t happened in my
personal experience.

The problem that I see is with using Modules is when traits have to be
exchanged during the life time of an instance. At least I didn’t manage
to include a Module and de-include if afterwards.

It has been brought up a few times here in the past:
Sometimes you want an object’s role to change so it would be nice if
there were some sort of uninclude or unextend
methods.

In the meantime, it probably wouldn’t be too hard to 'roll your own’
uninclude. Just get the list of instance methods from the module and
undef_method in the class. Something like:

class Module
def uninclude(mod)
mod.instance_methods.each {|meth|
undef_method meth
}
end
end

…I’m still figuring out how to do unextend (which is arguably more
useful than uninclude).

Phil

···

In message “OT: Traits” > > > on 04/02/14, Daniel Berger djberg96@hotmail.com writes:


(David A. Black) #12

Hi –

It has been brought up a few times here in the past:
Sometimes you want an object’s role to change so it would be nice if
there were some sort of uninclude or unextend
methods.

In the meantime, it probably wouldn’t be too hard to 'roll your own’
uninclude. Just get the list of instance methods from the module and
undef_method in the class. Something like:

class Module
def uninclude(mod)
mod.instance_methods.each {|meth|
undef_method meth
}
end
end

…I’m still figuring out how to do unextend (which is arguably more
useful than uninclude).

Maybe something like:

class Object
def unextend(mod)
(class << self; self; end) .class_eval <<-EOE
mod.instance_methods.each {|meth| undef_method(meth) }
EOE
end
end

David

···

On Tue, 17 Feb 2004, Phil Tomson wrote:


David A. Black
dblack@wobblini.net