#ifAbsentPut: - a summary

Bob Arning arning at charm.net
Wed Sep 2 13:58:39 UTC 1998


I think it will help me and perhaps others to see some of the examples that have been suggested listed together for comparison. If I haven't fairly stated your favorite, chime in. If I have, which one is it? I have ommitted other new methods that might be required to implement these proposals in order to focus more clearly on how one would write code to put the desired vales into a Dcitionary

--------
1. Which we might call the #ifAbsentPutValueOf: proposal

   d at: k ifAbsentPut: 7.		 "<- puts a value"
   d at: k ifAbsentPut: [7].  		"<- puts a block"
   d at: k ifAbsentPutValueOf: 7.        "<- is this allowed??"
   d at: k ifAbsentPutValueOf: [7].        "<- puts a value"

--------
2. Which we might call the simple #ifAbsentPut: proposal

   d at: k ifAbsentPut: 7.		 "<- puts a value"
   d at: k ifAbsentPut: [7].  		"<- puts a value"
   d at: k ifAbsentPut: [[7]].  		"<- puts a block"

--------
3. Which we might call the extended #ifAbsentPut: proposal. Rather than being a true proposal, I think this was an extension of #2 to provide greater consistency

   d at: k ifAbsentPut: 7.		 "<- puts a value"
   d at: k ifAbsentPut: [7].  		"<- puts a value"
   d at: k ifAbsentPut: [[7]].  		"<- puts a block"

so far the same as #2, but now we require that

   d at: k put: 10 factorial            "puts a 3628800"
   d at: k put: [10 factorial]          "puts a 3628800"
   d at: k put: [ [10 factorial] ]      "puts a block"

the obvious conclusion being that this would break things left and right.
=========

Cheers,
Bob





More information about the Squeak-dev mailing list