The Artima Developer Community
Sponsored Link

Agile Buzz Forum
ifNil: better named whenNil:

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
ifNil: better named whenNil: Posted: Jan 31, 2004 5:20 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: ifNil: better named whenNil:
Feed Title: Richard Demers Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rademers-rss.xml
Feed Description: Richard Demers on Smalltalk
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Richard Demers Blog

Advertisement

ifNil: better named whenNil:

In ifNil: isOK ifTrue: Vassili, makes a case for the fact that the #ifNil: methods return the receiver if the receiver is not nil. He provides three arguments:

  1. All other Smalltalks already do it that way. Tough to argue with that -- ask any parent.
  2. #at:ifAbsent: and #detect:ifNone: do it that way. This argument fails because both have a primary clause of at: or detect:. The alternative clause of ifAbsent: or ifNone: is to be taken only when the primary fails. The value returned by the primary clause is clearly to be used when the primary succeeds.

    Further, there is no sense that #at:ifAbsent: and #detect:ifNone: belong to the controlling protocol, as are the #ifNil: and #ifTrue: methods. In fact, they are in the accessing and enumerating protocols, respectively.

  3. #ifNil: should actually be seen as a value alternation method rather than as a control alternation method. Fine, then it just has a bad name. Perhaps #whenNil: would have been better, especially if it were in the accessing protocol. Naming things is always a tough business, with many trade-offs: functionality, linguistic redundancy, consistency, and readability -- as well as writability.

It's tempting to argue there should be some super language guru to decide such things -- a standards group, perhaps -- but that would go against the fundamental freedom that Smalltalk provides for innovation. Still, there should be some way for the entire Smalltalk community to propose, deliberate and decide how the language should evolve.

Read: ifNil: better named whenNil:

Topic: The state of modern viruses Previous Topic   Next Topic Topic: Software MFA Week 1 Status Report

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use