Conflicts between using respond_to? and extending Ruby

R

Rick DeNatale

I've always thought that the situation with programming languages is a
lot like that with musical instruments: they (languages or
instruments) all do the same thing (implement algorithms or make
music), but there's no denying, in either case, that different ones
have very different properties and provide very different experiences.

Not to mention different, and sometimes VERY different techniques to
'play' them.
 
Y

Yossef Mendelssohn

Not to mention different, and sometimes VERY different techniques to
'play' them.

For instance, playing a brass or woodwind instrument simply requires a
rest every now and then.

I'm not sure what the programming language analog is, maybe memory
management in C or something.
 
Y

Yossef Mendelssohn

as i was mentioning to david, my experience is that it just depends:
if you are writing something like

case conn
when TCPSocket
when UDPSocket
end

then is_a? is probably pretty strong - as strong as it possible in
ruby since we can always

def class() Lie end

Maybe I'm misunderstanding your point, but that doesn't do much.
x = [1,2,3] => [1, 2, 3]
x.is_a?(Array) => true
x.class => Array
def x.class() String; end => nil
x.class => String
x.is_a?(Array) => true
case x
when Array then 'arr'
when String then 'str'
else 'blah'
end
=> "arr"

I ran into this when I thought I was going to be able to use mock/stub
objects and handle is_a?/kind_of?/&c calls by stubbing the response to
class.
 
R

Rick DeNatale

For instance, playing a brass or woodwind instrument simply requires a
rest every now and then.

I was thinking more along the lines like you don't play a kettledrum
with a guitar pick, or a guitar with mallets. (At least not usually).
I'm not sure what the programming language analog is, maybe memory
management in C or something.

A better analogy here might be playing a woodwind, where you have to
do your own "breath management" vs. playing a pipe organ, which has a
"breath collector!"
 
D

David A. Black

Hi --

I was thinking more along the lines like you don't play a kettledrum
with a guitar pick, or a guitar with mallets. (At least not usually).

I think I took the bit about hitting a clarinet with a violin bow, or
a basketball with a golf club, out of my "Coming from Ruby" article
before it saw the light of day, but there are definitely some amusing
possibilities there :)
A better analogy here might be playing a woodwind, where you have to
do your own "breath management" vs. playing a pipe organ, which has a
"breath collector!"

What about the old days, when you'd have an apprentice working the
bellows while you played?


David

--
Upcoming training by David A. Black/Ruby Power and Light, LLC:
* Advancing With Rails, Edison, NJ, November 6-9
* Advancing With Rails, Berlin, Germany, November 19-22
* Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.rubypal.com for details!
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top