From: Charlie Bowman Date: 2006-03-03T03:55:10+09:00 Subject: Re: cleaner Ruby in a rails view --=-iYMPYMsjAJXHpxWUOUNb Content-Type: text/plain Content-Transfer-Encoding: 7bit The only time this nil problem occurs for me is with rails views. With all other ruby (about half my time is spent in ruby and the other half web apps) code, I never have the nil problem unless I've written bad code. I feel like web templates should not throw errors if you pass nil values. On Fri, 2006-03-03 at 03:07 +0900, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: cleaner Ruby in a rails view" > on Fri, 3 Mar 2006 01:38:38 +0900, "Brian Cully" writes: > > |I would love for ruby's nil to behave properly, as it does in lisp and > |objc. You can ask nil anything, but all you're going to get back is nil. > > Which one behave more properly? Lisp, or Objective-C? Since they > have different behavior for nil[1]. For your information, you can define > something like nil in Objective-C by yourself, using the combination > of BlankSlate and method_missing. Or you can even hack the > interpreter to make nil behave "properly"[2]. It's pretty easy. > > matz. > > [1] Try (1+ nil) in your Lisp REPL. In Lisp, nil is just a (), not > that something which returns nil for every request, like one in > Objective-C. > [2] But I'm sure you will soon find out making nil behave like you > want is a pretty bad idea. Trust me. I did it 10 years ago. It > swallowed so many errors, and made my debugging horrible. Perhaps > a separated special value dedicated for the purpose might be > better. > Charlie Bowman http://www.recentrambles.com --=-iYMPYMsjAJXHpxWUOUNb--