<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>
I am not decided against the generalized null pattern just yet [1].&nbsp; I just wanted to point out that no one is going to put 5 temps in a row like that.&nbsp; The exception might be more common but I never see it.<br><br>[1] I am not going to say it's bad, nor am I convinced it is a sure win.&nbsp; Personally I can't recall a single time I have needed something like this.&nbsp; I do tend to chain messages often, but I guess I only do that when I don't expect a nil.&nbsp; If one comes up I want to see it right then to track it down.&nbsp; But perhaps in other domains then I have been programming in so far it would come up more.&nbsp; At any rate I'm glad it's out there to try out if I need it.&nbsp; Thanks for that Keith.<br><br>&gt; From: water@tunes.org<br>&gt; Date: Thu, 26 Jul 2007 12:41:05 -0700<br>&gt; To: squeak-dev@lists.squeakfoundation.org<br>&gt; Subject: Re: Message Eating Null - article<br>&gt; <br>&gt; Hello,<br>&gt; <br>&gt; I would like to point out that both of these claims are unrealistic.<br>&gt; <br>&gt; Specifically, Keith's examples all use low-level control-flow  <br>&gt; messages like "notNil ifTrue: [" whereas non-novice Smalltalkers  <br>&gt; should be using "ifNotNil:" and "ifNotNilDo: [:obj |".<br>&gt; <br>&gt; The example would best be:<br>&gt; <br>&gt; widget setStringValue: (#(office phone lastNumberDialed asString)  <br>&gt; inject: person into: [:obj :sel | obj ifNotNil: [obj perform: sel]])<br>&gt; <br>&gt; without the message-eating Null pattern. Or if #perform: irks you,  <br>&gt; you can use:<br>&gt; <br>&gt; widget setStringValue: (person office ifNotNilDo: [:office | office  <br>&gt; phone ifNotNilDo: [:phone | phone lastNumberDialed ifNotNilDo:  <br>&gt; [:number | number asString]]])<br>&gt; <br>&gt; Like Keith, I find this a problem to have to write and maintain in  <br>&gt; code, but I'm not compelled to write long essays on it. I tend to  <br>&gt; think that chained message-sends represent a way in which distantly- <br>&gt; related code can reach across protocols a bit too far. And Keith is  <br>&gt; being a bit unfair in that a several-page-long essay (with a really  <br>&gt; wide column justification width) will not be adequately rebutted in  <br>&gt; an email forum, thus keeping the discussion from balance.<br>&gt; <br>&gt; My own view is that message-eating null is usable in controlled  <br>&gt; circumstances, but that in general one cannot control the  <br>&gt; circumstances (you can't know who *won't* receive a null as a  <br>&gt; parameter, so code written without that in mind fails in strange  <br>&gt; ways) in Smalltalk-80.<br>&gt; <br>&gt; It is also worth pointing out that "message-eating null" most closely  <br>&gt; resembles the apposition of type T to NIL in Lisp, where one is the  <br>&gt; supertype of every type and the other is the subtype of every type.  <br>&gt; In Lisp, you do not interchange these, for good reason that I believe  <br>&gt; applies here but don't have time to gather evidence in support.<br>&gt; <br>&gt; I think his packages which use message-eating-null would be a lot  <br>&gt; more palatable if they didn't...<br>&gt; <br>&gt; On Jul 26, 2007, at 12:06 PM, Keith Hodges wrote:<br>&gt; <br>&gt; &gt;&gt; Yuck, I wouldn't do either of those.  I would do:<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; widget setStringValue: #(office phone lastNumberDialed asString)  <br>&gt; &gt;&gt; inject: person into: [:obj :sel| o == nil ifTrue: [ nil ] ifFalse:  <br>&gt; &gt;&gt; [ obj sel ] ]<br>&gt; &gt; you would?<br>&gt; &gt;<br>&gt; &gt; To me the above looks as close to perl as smalltalk is hopefully  <br>&gt; &gt; ever likely to get!<br>&gt; &gt;<br>&gt; &gt; ;-)<br>&gt; <br>&gt; That is disingenuous. Please use honest arguments.<br>&gt; <br>&gt; &gt; Keith<br>&gt; &gt;<br>&gt; &gt; p.s. Someone once accused me of being a PL/1 programmer in a former  <br>&gt; &gt; life.<br>&gt; <br>&gt; --<br>&gt; -Brian<br>&gt; http://briantrice.com<br>&gt; <br>&gt; <br><br /><hr />Local listings, incredible imagery, and driving directions - all in one place! <a href='http://maps.live.com/?wip=69&FORM=MGAC01' target='_new'>Find it!</a></body>
</html>