Would this be of interest in general... I have always wanted a more capable
literal array than what we have now..
#( 123 23 'das' )
whynot:
#( 'ac'->23 2->'casd' myVar1) ... evaluates to a collection..
so I just tried this out with a BlockClosure:
asArray
| stmts anArray |
stmts := self decompile statements.
anArray := Array new: stmts size.
stmts doWithIndex: [ :eaNode :indx| | start end value|
start := (eaNode asString indexOf: ${)+1.
end := (eaNode asString lastIndexOf: $})-1.
value := Compiler evaluate: (eaNode asString copyFrom: start to:
end) for: self receiver logged: false.
anArray at: indx put: value].
^anArray
So we could do:
['abc'->123. 'def'->456. 'efg'->789. 'hij'->123. 'klm'->456.] asArray.
[self checkThisUsingKeywordMethod: 'abc' with:'efg'. localVar1. instanceVar1
] asArray
to yield arrays.. not neat, I would much rather prefer the literals do their
job their way...
but works.. for the narrow set I have tried so far..
Any comments..
-Skrish
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project