On Apr 1, 2011, at 10:10 AM, Friedrich Dominicus wrote:
> AxiNat <[email protected]> writes:
>
>> Hi Friederich, here's two simple optimizations:
>>
>> #(#nul #soh #stx #etx #eot #enq #ack #bel #bs #tab #lf)
>> withIndexDo: [:each :index |
>> self class compile: each asString , ' ^ asciiField at: ', index
>> asString.].
>>
>> Array withAll: #(1 2 3) is equivalent to #(1 2 3), and if you're not going to
>> use the array again, you don't even need to assign it to a variable :)
> Well I do not want the compile part with String
So you could override #doesNotUnderstand: and there check if someone
sends a message #etx (and the others) and then return the value. (you then want
to
store the value in a dictionary keyed by the the message name).
doesNotUnderstand: aMessage
| dict |
dict := (#(nul soh stx etx eot enq ack bel bs tab lf) collectWithIndex:
[:elem :index |
elem -> index]) asDictionary.
^dict at: aMessage selector ifAbsent: [^super doesNotUnderstand:
aMessage].
But of course doesNotUnderstand: is always a bit magic... and should be used
with care.
As for strings stiched together: yes, *horrible*. And we plan to move on to
something
better soon.
In general, I like the idea to have a reflective model of the structure of
methods...
When talking about code, we should not use string... the Quasi-Quoting from
Helvetia is far better than string manipulation:
http://scg.unibe.ch/research/helvetia/examples#168249369
That combined with a good AST should make these things much easier.
Marcus
--
Marcus Denker -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.