The duck's backside

R

Robert Dober

And his description of Eiffel, "Quintessentially French!"
Do you mean it works like the TGV but nobody really knows why? Ok I
guess I have to leave my wife's country now ;).
Robert
 
D

David Masover

IMHO this is a gross generalization!

I guess that you might indeed use Ruby classes as categories in your
designs. I do not know what others do, but the simple fact that I use
Ruby classes for other things falsifies your statement.

Give me an example of a class that isn't a category.

It might not be a category as far as your program logic is concerned, but it's
certainly a category of some kind. NilClass is a category of objects for whom
#nil? returns true, for example.
 
J

Joel VanderWerf

David said:
Give me an example of a class that isn't a category.

It might not be a category as far as your program logic is concerned, but it's
certainly a category of some kind. NilClass is a category of objects for whom
#nil? returns true, for example.

class MyNil
def nil?
true
end
end

p MyNil.new.nil?
 
D

David Masover

class MyNil
def nil?
true
end
end

p MyNil.new.nil?

Interesting that this works -- but it doesn't disprove my point. Humans are a
category of mammals -- that doesn't imply that all mammals are humans.

Now, technically, you should be able to do it the other way around, right?

class NilClass
def nil?
false
end
end

That would make my statement invalid. But doing so is evil:

$ irb
irb(main):001:0> # Control statement
irb(main):002:0* true
=> true
irb(main):003:0> class NilClass
irb(main):004:1> def nil?
irb(main):005:2> false
irb(main):006:2> end
irb(main):007:1> end
=>
irb(main):008:0> # Another control statement... can we make it that far?
/usr/lib/ruby/1.8/irb/slex.rb:235:in `match_io': undefined method `call' for
nil:NilClass (NoMethodError)
from /usr/lib/ruby/1.8/irb/slex.rb:222:in `match_io'
from /usr/lib/ruby/1.8/irb/slex.rb:76:in `match'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:287:in `token'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:263:in `lex'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:234:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in `loop'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in `catch'
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in
`each_top_level_statement'
from /usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /usr/lib/ruby/1.8/irb.rb:69:in `start'
from /usr/bin/irb:13
 
R

Robert Dober

I know I do not have the communication talents of Jo=EBl and David, well
he's kind of cheating, it is his profession ;). But I really fail to
understand your reasoning, as a matter of fact Jo=EBl's code was *not*
modifiying the category animal but human.
Maybe reading the link David gave above will help you to understand
our mindset, well we do not even have exactly the same either, which
is a good thing :).

But that does not mean that you have to adapt it of course!!!

Cheers
Robert
--=20
http://ruby-smalltalk.blogspot.com/
 
J

Joel VanderWerf

Joel said:
I hereby claim "turducken typing", but I have no idea what it means. ;)

Proposed definition: code that combines chicken and duck typing and
makes the programmer look like a turkey.
 
A

Avdi Grimm

Interesting that this works -- but it doesn't disprove my point. Humans are a
category of mammals -- that doesn't imply that all mammals are humans.

Humans are a category of animal with certain characteristics which set
them apart form other animals. All animals which have those
characteristics are human. You stated the theory that the NilClass
class encompasses all objects that respond positively to #nil?. Which
is easily disproved by defining a non-NilClass which responds
positively to nil. MyNil is in the *category* of objects which
respond to #nil? in the affirmative, but not in the *class* NilClass.
Thus, NilClass != the category of objects which respond to #nil?

NilClass objects may be a *subset* of the #nil? => true category, but
NilClass itself does not define a category other than "objects which
are instances of NilClass".

--
Avdi

Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top