Info on Smalltalk DSLs or Metaprogramming...

Bert Freudenberg bert at impara.de
Tue Aug 22 21:28:16 UTC 2006


Am 22.08.2006 um 21:22 schrieb Rich Warren:

>
> On Aug 22, 2006, at 2:36 AM, Bert Freudenberg wrote:
>
>> Rich Warren schrieb:
>>> Ruby's literal hashes are not great from a non-geek legibility  
>>> viewpoint, but if you're making a DSL for coders, they're brilliant.
>>
>> Aren't Smalltalk dictionaries equally legible?
>>
>> {
>>   'one' -> 1.
>>   'two' -> 2.
>>   'foo' -> 42.
>> } as: Dictionary
>>
>> - Bert -
>>
>
> I'd argue Ruby (can be) a little more streamlined. If it's the last  
> parameter, you don't need any brackets. And it doesn't need the as:  
> Dictionary call.

well, if you insist on getting rid of the brackets in your DSL, this  
is legal Smalltalk:

	'one' -> 1, 'two' -> 2, 'foo' -> 42

Challenge: make that expression answer the dictionary as above

Solution: attached, but try yourself first ;)

- Bert -





More information about the Squeak-dev mailing list