[ANN] traits-0.0.0

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

http://homepages.ihug.com.au/~naseby/33.html
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf

Dan

···

-----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?search=traits
   http://codeforpeople.com/lib/ruby/traits

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 :wink:

depends on your definition:

harp:~ > lynx -dump http://thesaurus.reference.com/search?q=attribute | grep -A2 -i synonym | head -3
    Synonyms: aspect, character, characteristic, facet, idiosyncrasy,
    indication, mark, note, particularity, peculiarity, point, property,
    quality, quirk, sign, speciality, symbol, trait, virtue

cheers.

-a

···

On Wed, 4 May 2005, Berger, Daniel wrote:

-----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?search=traits
   http://codeforpeople.com/lib/ruby/traits

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 :wink:

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

http://homepages.ihug.com.au/~naseby/33.html
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

Berger, Daniel wrote:

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

http://homepages.ihug.com.au/~naseby/33.html
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf

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

traits.rb (1.1 KB)

"Berger, Daniel" <Daniel.Berger@qwest.com> writes:

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 :wink:

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

Yeah, I thought that too... to me traits are mix-ins (possibly limited
in access of instance variables). I think they are the same in Self.

···

Dan

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

...

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

http://homepages.ihug.com.au/~naseby/33.html
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf

depends on your definition:

http://thad.notagoth.org/cpptraits_intro/

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

···

Ara.T.Howard@noaa.gov wrote:

On Wed, 4 May 2005, Berger, Daniel wrote:

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.

i actually had the whole thing wrapped in a Traits module... i'm ok with this
approach if people don't mind doing an include. one other positive thing is
that this does not pollute Module and Class with new methods...

i'll bang out a

   module Trait
     module AccessorTraits
     end
   end

now and read more about MethodTraits before tackling - this was a nice
diversion while i've been on leave but 'real' work starts back up today so i
won't have time for a while...

cheers.

--------------080906010603050401010206
Content-Type: text/plain;
name="traits.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="traits.rb"

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/~naseby/33.html
    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

--------------080906010603050401010206--

-a

···

On Wed, 4 May 2005, Zach Dennis wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

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 :wink:

however the former is also quite clear.

opinions welcome - it's a simple matter to swtich it.

cheers.

-a

···

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/~naseby/33.html
http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf

depends on your definition:

http://thad.notagoth.org/cpptraits_intro/

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

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

...

  class C
    trait 'a'
  end

sure is nice and short :wink:

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.

···

Ara.T.Howard@noaa.gov wrote:

> ..
>>> This doesn't seem to have anything to do with traits:
>>>
>>> http://homepages.ihug.com.au/~naseby/33.html
>>> http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf
>>
>>
>> depends on your definition:
>
> http://thad.notagoth.org/cpptraits_intro/
>
> 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 :wink:

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 :slight_smile:

btw, very cool stuff!

···

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:

cheers.

-a

--
Bill Guindon (aka aGorilla)

Noooo! I've already got 1000 lines of ruby code dependent on this module!
Just kidding.

It is very handy. Thanks

···

Ara.T.Howard@noaa.gov wrote:

hmm. i'll change it back to 'attributes' if people are going to use
it but don't like the name. tom complained that

--
J. Lambert

i like it - but name clashes...

anyone else have thoughts?

-a

···

On Wed, 4 May 2005, Joel VanderWerf wrote:

Ara.T.Howard@noaa.gov wrote:
..

  class C
    trait 'a'
  end

sure is nice and short :wink:

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.

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

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

cool. thats 3 for and 2 against.

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

you started in on the beer before i did !

btw, very cool stuff!

thanks - it __very__ prototypical still.

-a

···

On Wed, 4 May 2005, Bill Guindon wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

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 :slight_smile:

What about "member"?

Regards,

Peter

···

Ara.T.Howard@noaa.gov wrote:

anyone else have thoughts?

ok - an alias for 'has' :wink:

-a

···

On Wed, 4 May 2005, gabriele renzi wrote:

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 :slight_smile:

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

for some reason that implies either a function or bad joke to me :wink:

-a

···

On Wed, 4 May 2005, Peter C. Verhage wrote:

Ara.T.Howard@noaa.gov wrote:

anyone else have thoughts?

What about "member"?

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================