[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: [ANN] traits-0.0.0

Berger, Daniel

5/3/2005 8:59:00 PM

> -----Original Message-----
> From: Ara.T.Howard [mailto:Ara.T.Howard@noaa.gov]
> Sent: Tuesday, May 03, 2005 2:45 PM
> To: ruby-talk ML
> Subject: [ANN] traits-0.0.0
>
>
>
> URLS
>
> http://raa.ruby-lang.org/search.rhtml?sea...
> http://codeforpeople.com/lib/r...
>
> ABOUT
>
> traits.rb aims to be a better set of attr_* methods and
> encourages better
> living through meta-programming and uniform access
> priciples. traits.rb
> supercedes attributes.rb. why? the name is shorter ;-)

This doesn't seem to have anything to do with traits:

http://homepages.ihug.com.au/~nase...
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02b...

Dan




22 Answers

Ara.T.Howard

5/3/2005 9:18:00 PM

0

Joel VanderWerf

5/3/2005 9:43:00 PM

0

Ara.T.Howard@noaa.gov wrote:
> On Wed, 4 May 2005, Berger, Daniel wrote:
...
>> This doesn't seem to have anything to do with traits:
>>
>> http://homepages.ihug.com.au/~nase...
>> http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02b...
>
>
> depends on your definition:

http://thad.notagoth.org/cpptra...

But that shouldn't cause any confusion to ruby folks...


Ara.T.Howard

5/3/2005 10:07:00 PM

0

Joel VanderWerf

5/3/2005 10:47:00 PM

0

Ara.T.Howard@noaa.gov wrote:
...
> class C
> trait 'a'
> end
>
> sure is nice and short ;-)

If you want short:

class C
has 'a'
class_has 'b'
end

That completely avoids the issue of what 'a' is, an attribiute, a trait,
a getter/setter, etc.


Bill Guindon

5/3/2005 10:54:00 PM

0

On 5/3/05, Ara.T.Howard@noaa.gov <Ara.T.Howard@noaa.gov> wrote:
> On Wed, 4 May 2005, Joel VanderWerf wrote:
>
> > Ara.T.Howard@noaa.gov wrote:
> >> On Wed, 4 May 2005, Berger, Daniel wrote:
> > ..
> >>> This doesn't seem to have anything to do with traits:
> >>>
> >>> http://homepages.ihug.com.au/~nase...
> >>> http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02b...
> >>
> >>
> >> depends on your definition:
> >
> > http://thad.notagoth.org/cpptra...
> >
> > But that shouldn't cause any confusion to ruby folks...
>
> hmm. i'll change it back to 'attributes' if people are going to use it but
> don't like the name. tom complained that
>
> class C
> attribute 'a'
> end
>
> was slightly verbose and
>
> class C
> class_attribute 'a'
> end
>
> verboser still.
>
> class C
> trait 'a'
> end
>
> sure is nice and short ;-)
>
> however the former is also quite clear.
>
> opinions welcome - it's a simple matter to swtich it.

I like 'traits', it's a good synonym for attributes, even gets all of
it's letters from it.

For some strange reason, 'towels' also seems like it might work :)

btw, very cool stuff!

> cheers.
>
> -a


--
Bill Guindon (aka aGorilla)



Ara.T.Howard

5/3/2005 10:56:00 PM

0

Ara.T.Howard

5/4/2005 2:28:00 AM

0

Zach Dennis

5/4/2005 5:07:00 AM

0

Berger, Daniel wrote:
>
> This doesn't seem to have anything to do with traits:
>
> http://homepages.ihug.com.au/~nase...
> http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02b...
>

I like where Ara is going and I like where Naseby went. I think both of
these solutions go hand in hand. Included is an example/test usage (yes
it runs) of how it appeals to me.

Basically they should both be 'traits'. Please see example rb file for
more information.

Zach


module Trait
##
# use append_features so if the user includes Trait it will get everything
# from with AccessorTrait and MethodTrait also. see
def self.append_features( aModule )
constants.each { |c| aModule.instance_eval( "include #{c}" ) }
end

module AccessorTraits
# include Ara's code here
def trait( arg )
puts "#{self} has trait #{arg}"
end
end

module MethodTraits
# include here the functionality from
# http://homepages.ihug.com.au/~nase...
def require_method( arg )
puts "#{self} has required method #{arg}"
end
end
end


## Example Usage

class A
# includes Trait, so it gets all of Traits functionality
include Trait
end
A.new.trait( :a )
A.new.require_method( :reqA )
puts

class B
# includes AccessorTraits, only gets AccessorTraits functionality
include Trait::AccessorTraits
end
begin
B.new.trait( :b )
B.new.require_method( :reqB )
rescue => ex
puts ex
end
puts

class C
# includes MethodTraits, only gets MethodTraits functionality
include Trait::MethodTraits
end
begin
C.new.trait( :b )
rescue => ex
puts ex
C.new.require_method( :reqC )
end
puts



Peter C. Verhage

5/4/2005 6:25:00 AM

0

Ara.T.Howard@noaa.gov wrote:
> anyone else have thoughts?

What about "member"?

Regards,

Peter

gabriele renzi

5/4/2005 7:42:00 AM

0

Joel VanderWerf ha scritto:

> If you want short:
>
> class C
> has 'a'
> class_has 'b'
> end
>
> That completely avoids the issue of what 'a' is, an attribiute, a trait,
> a getter/setter, etc.

+1 lovely :)