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

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to