Hi, What you seek is something like - Dolphin ##( ) construction - or VW [] once trick from Travis Grigg based on using the #become: power (search once upon a time or something like that on his blog) I was thinking of this very subject recently and have a draft proposition not really ready (must think of it twice).
The first idea would be to use the existing indirection for shared variables by always access their value via a message send. With a class implementing #value with a second indirection, this could solve the problem of package load order and cyclic dependencies, as well as shared variable initialization by using systematic lazy evaluation schemes. The second idea would be to define static variables local to the method (thus not shared) using the same #value principle, but there we need a syntax extension (something I just can't decide by myself). With such scheme, direct access to the value is not possible, so VM optimization fetching the second ivar or JIT techniques might have to be changed. Impact on performance has to be studied. However, polymorphic inline cache could eventually reduce this negative impact. Nicolas 2010/7/22 Sudhakar Krishnamachari <[email protected]> > 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 >
_______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
