help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] short list of possible smalltalk extensions


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] short list of possible smalltalk extensions
Date: Sun, 05 Dec 2010 11:23:20 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6

On 12/05/2010 09:55 AM, Sungjin Chun wrote:
I like these extensions :-) But one question, how about compatibility?

These would all be backwards compatible. To some extent, conversion to other dialects could be achieved with rewrite rules
or with wrappers in the class library.

For example

   [ :args... | args asSet ]

could be equivalent to

   [ :args | args asSet ] asVariableArgumentsBlock

with

BlockClosure subclass: VariableArgumentsBlock [
    value [ ^super value: Array new ]
    value: x [ ^super value: {x} ]
    value: x value: y [ ^super value: {x. y} ]
    value: x value: y value: z [ ^super value: {x. y. z} ]
    valueWithArguments: args [ ^super value: args ]

    BlockClosure >> asVariableArgumentsBlock [
        ^self changeClassTo: VariableArgumentsBlock
    ]
]

Example:

st> b := [ :args  | args asSet ] asVariableArgumentsBlock
a VariableArgumentBlock
st> b value: 1 value: 232 value: 432
Set (432 1 232 )

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]