On Mon, Jun 2, 2008 at 5:07 PM, Rick DeNatale [email protected]
wrote:
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
Dave T., who coined the term “duck typing”, has described it as
“a way of thinking about programming in Ruby.”
Do you know when he actually started speaking about “duck typing”?
Did he? I learned the term in connection with Python, a long long
time ago. The wikipedia article on duck typing seems to support the
idea that the term comes from that camp:
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.
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.
On Tue, Jun 3, 2008 at 2:03 AM, David M. [email protected]
wrote:
I know I do not have the communication talents of Joël 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ël’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!!!
On Monday 02 June 2008 17:48:38 Joel VanderWerf wrote:
David M. wrote:
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?
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 methodcall’
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:inmatch’
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:287:in token' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:263:inlex’
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:inloop’
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:incatch’
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:ineval_input’
from /usr/lib/ruby/1.8/irb.rb:70:in start' from /usr/lib/ruby/1.8/irb.rb:69:incatch’
from /usr/lib/ruby/1.8/irb.rb:69:in `start’
from /usr/bin/irb:13
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”.