Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Dir.bitbucket?
Logan Capaldo
8/23/2006 2:57:00 AM
On Aug 22, 2006, at 10:37 PM, John Johnson wrote:
> On Tue, 22 Aug 2006 17:44:42 -0400, Logan Capaldo
> <logancapaldo@gmail.com> wrote:
>
>>
>> On Aug 22, 2006, at 1:36 PM, John Johnson wrote:
>>> How about:
>>>
>>> oblivion = File.open(nil, 'w')
>>>
>>> Seems intuitive.
>>>
>>
>> For what definition of intuitive? nil is not a path, it's not even
>> a string that could represent a path.
>
> Exactly.
>
> What happens when you write to a nil file? Nothing.
>
You get an exception when you write to a nil file in ruby.
>> file = nil
=> nil
>> file.write "Whee"
NoMethodError: undefined method `write' for nil:NilClass
from (irb):2
Which is as it should be.
> Where does the stuff go? Nowhere.
>
nil is not a file. It is also not "nowhere". (If it was nowhere, it
would probably behave a bit more like Objective-C's nil). Even if it
was nowhere, we would have all sorts of fun tracking down bugs where
we meant to open a file ( a real file ) and forgot to check for nil
earlier in the code. Our output would unintentionally disappear never
to be seen again. Also the docs would be especially fun, "File.open
takes a path to file and a mode, well sometimes it takes nil, which
means open the platform specific 'bitbucket'".
Repurposing nil for this is not a good idea IMO. It reminds me of
perl where writing to unopened file handles silently throws data away.
> Oh yeah, it also doesn't have to be translated into 150 languages
> like 'bit bucket' would.
>
"bit bucket" is not the only possible name for this.
> Regards,
> JJ
>
>
> --
> Using Opera's revolutionary e-mail client:
http://www.opera...
>
>
1 Answer
Trans
8/23/2006 7:16:00 PM
0
Logan Capaldo wrote:
> "bit bucket" is not the only possible name for this.
Yea, I'm thinking a good name would be "bitchbucket" ;-)
T.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Dir.bitbucket?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password