j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Hi all,
One of the handy things things things perl does is allow you to stick variable names in strings and have them be replaced by the actual value of the variable. The attached goody adds the same capability to Squeak.
Here's an example DoIt:
| container bev place |
(99 to: 90 by: -1) do: [ :count | container := #('bottles' 'flagons' 'glasses' 'cases') atRandom. bev := #('beer' 'Coke[tm]' 'vodka') atRandom. place := #('wall' 'shelf') atRandom.
Transcript nextPutAll: '$count $container of $bev on the $place.\n' likePerl; endEntry. ]
Note that a simple unary message (#likePerl) makes the copy and does the interpolation. There's no argument required, unlike Python[1].
On the other hand, this will probably stop working if the sources go missing or BlockContexts get upgraded to full closures. Oh well.
--Chris
[1] Not to disparage Python.
Attachments:
squeak-dev@lists.squeakfoundation.org