H
Hal Fulton
Joel said:(Apologies to Eric Idle.)
Now there's a role model. I'd love to be like him,
just on the other side of the Atlantic. A sort of
American Idle.
Hal
Joel said:(Apologies to Eric Idle.)
Ah, but _would_ it. On any other object I would agree with you.
But nil occupies a special place in the ruby world.
nil means in effect, no thing is here.
What happens if I tell no thing to do something.
No thing happens and I'm left with no thing.
Is your assertion correct?
Do you actually generate incorrect PDF? (In which case you are right)
Does it just plain work? (In which case I am right)
Or does it blow up with an exception or error report somewhen
else? (I which case I'm still right.)
I'm better a beer (to be collected in Christchurch New Zealand)
that practical software will find that...
a) Mostly it will just do the right thing.
b) Otherwise it will do the right thing for now, and be caught later as an
Exception or error report. (I suspect by adding a few more things like
class NilClass
def respond_to?( sym)
true
end
end
may cure some of those...
c) And very rarely, far more rarely than people suspect, will it
silently do the wrong thing.
Also as you go along, consider cases where you could just drop
conditionals. How many if branches would you be quietly dropping?
As for debugging, if you look at the RCR, the implementation I
give creates state on nil that records which method was missing
and in which calling context.
From: "John Carter said:Prove me wrong, take the challenge.
Next time your pet program dies of a NoMethodError for NilClass add
class NilClass
def method_missing(sym,*args)
nil
end
end
...at the head of your program.
See empirically what happens. Does it hide bugs? Does it just work? Does
it still throw an exception or give an error message?
Cyent said:Think of an array with 42 elements. Access element 55. It returns nil. How
is this different?
If you think through the default values for arithmetic operations on nil
properly. My guess is the results in most case will be right.(How often do
you initialize an array to 55? 99.9% of the time you expect it to be full
of 0 or maybe 1.
How about nil autoconverts to the identity element for all operations. ie.
0 for +, 1 for *, "" for string concat.
In which case more code simplification, more code that just works.
Is it?
I wwnt grepping through ruby 1.9 CVS (ok its a month or two old version)
looking for some code that will break.
I don't believe _anything_ will (currently) break.
If I prove wrong, I will gladly retract my RCR and apologise.
Ryan said:The burden of proof (that this is needed) must sit on you, not on us
(that this is not needed).
Either way, I still agree with Eric, there is no reason for this to be
an RCR since the whole thing is 5 simple lines of ruby that any user
can selectively use as they see fit. If someone wants to use it, they
require a very small file. If they don't want to use it, they don't do
anything special.
The burden of proof (that this is needed) must sit on you, not on us (that
this is not needed).
Either way, I still agree with Eric, there is no reason for this to be an RCR
since the whole thing is 5 simple lines of ruby that any user can selectively
use as they see fit. If someone wants to use it, they require a very small
file. If they don't want to use it, they don't do anything special.
Yes, and the nil.blackhole switch is a very handy idea; one could turn this
on and off for blocks of code where the alternative behavior seemed useful.
David said:Hi --
On Sat, 7 May 2005, James Britt wrote: ...
I don't think it would be thread-safe, would it? (I'm thinking back
to the wall I hit when working on Ruby Behaviors....)
Hi,
In message "Re: RCRs that can be implemented in Ruby (was: Re: Prove me Wrong! Re: RCR 303: nil should accept missing methods)"
|> Either way, I still agree with Eric, there is no reason for this to be an RCR
|> since the whole thing is 5 simple lines of ruby that any user can selectively
|> use as they see fit. If someone wants to use it, they require a very small
|> file. If they don't want to use it, they don't do anything special.
|
|I'm a little puzzled by this (the idea that changes that can be
|implemented in Ruby should not be RCRs), which I hadn't heard before
|Eric's post, but which seems to be taking Seattle by storm
There's no such official rule for RCRs; actually there's no official
rule for RCRs at all. But if the idea can be easily implemented in
pure Ruby, one can release it to the public before submitting an RCR
to prove its usefulness by real experiences.
Besides that, if
everyone submit every idea popped in his mind, whole RCR process would
overflow. Eric (and Ryan) might think of such case.
Joel said:$ ruby missing_obj.rb
#<NoMethodError: undefined method `lookup' for nil:NilClass>
#<MissingDatabase: missing_obj.rb:26: No user input>
Ryan said:The burden of proof (that this is needed) must sit on you, not on us
(that this is not needed).
Cyent said:Anybody who is vaguely worried about bugs in their code whether they are
running perl or ruby should _always_ use the -w switch.
=20=20
I, for one, would rather see it throwing an error as it is now. Dead=20 programs
don't tell lies.
I agree. In fact, to quote
http://www.adamsmith.org/logicalfallacies/000656.php
You may, however, be left with incorrect output.
"\n#{@oid} 0 obj\n<</Type /Page /Parent #{@owner.oid} 0 R >>"
If @owner is nil, then using your proposal I will get:
234 0 obj
<</Type /Page /Parent 0 R >>
Le 8/5/2005 said:Hmm. Interesting.
Hard real, live, data.
I like it.
Let's look at it a bit more closely.
How did the nil get into @owner? Would it have been picked up by -w?
Was it placed there yourself in the meaning "uninitialised" or in the
meaning "no thing here"? By what route did it arrive?
Given my new proposal of having an uninitialised vs nothing
types of nil?
Could we design things in a way that would resolve your
issue?
John Carter
Hmm. Interesting.
Hard real, live, data.
I like it.
Let's look at it a bit more closely.
How did the nil get into @owner? Would it have been picked up by -w?
Was it placed there yourself in the meaning "uninitialised" or in the
meaning "no thing here"? By what route did it arrive?
Given my new proposal of having an uninitialised vs nothing
types of nil?
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.