[Top][All Lists]

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

[Help-smalltalk] short list of possible smalltalk extensions

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

1) nested classes. GNU Smalltalk already supports Class.ClassVar notation to access class variables. This could be easily extended to support nested classes, all it requires is parser support.

Note these wouldn't be closures like Java inner classes, they would just use the class pool dictionary as a namespace.

        hidden complications: GUI support, fileout support,
        reflection support

2) additional binary operators.  This can come in many ways:

2.a) ".." instead of #to:. Also make the compiler recognize "a .. b do: []" and similar.

2.b) Unicode binary operators. Less-than-or-equal for example. Let's wait for Perl 6 which also has those though. :)

3) additional literals.   #/abc/ for Regex, for example.

4) A magic DWIM "match" (I'll call it #=~) and "transform" (#<<) operator:

        [:a | true] =~ something   matches everything
        #/abc/ =~ something        means something matches regex
        #(1 3 5 10) =~ something   means something is in the collection
        'aeiouy' =~ something      strings are not special, but...
        #even =~ something         ... means "something even == true"

        [:a | a] << something      is the identity
        #/\[.*\]/ << something     gives the first regex match
        #(1 2 4 8) << something    maps key to value
        '0123456789' << something  strings are not special, but...
        #abs =~ something          ... symbols are

#select: and #reject: use #=~, #collect: uses #<<. It is also possible to use keyword methods, of course.

5) Extended blocks:

5.a) Anonymous variables for blocks.

        x select: [ _ even ]
        1..10 fold: [ _ + _ ]

5.b) Variable-argument blocks

        [ :r :m :a... | r perform: m withArguments: a ]
            value: 1 value: #+ value: 2

5.c) Optional (efficient) currying:

        plus := [ :r :m :a... | r perform: m withArguments: a ] curry
            value: 1 value: #+.

        plus value: 2 "=> 3"

Any more ideas?


reply via email to

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