Re: scoped crm114 script variables --> in case you were wondering about match/bound vars, or: two mind altering substances that come out of MA, USA
Paolo <[email protected]>
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <20090226150904.GD8801@localhost> |
On Thu, Feb 26, 2009 at 01:15:02PM +0100, Ger Hobbelt wrote: missing test: > :capture_func: > isolate (:z:) /abcdefghijklmnop/ # make :z: be local > match [:z:] /...(...).../ ( :: :a: ) # capture :a: into :z: + match [:z:] /......(...)/ ( :: :x: ) # capture :z: into :x: > match <keep> [:z:] /(......).../ ( :: :b: ) # capture :b: into :z: > output /:*:_cd:: :a: is :*:a:, :z: is :*:z:, :b: is :*:b:\n/ + output /:*:_cd:: :x: is -:*:x:-\n/ and same output on :x: at level 0, where I'd expect just ':x:' since it wasn't already defined at level 0. > This will produce on bleeding edge GerH, which has full support for > scoped variables: > > ------------------------ > 1: :a: is def, :z: is abcdefghijklmnop, :b: is abcdef ... > crm114: *WARNING* > Attempt to alter the value of a nonexistent variable, so I'm creating > an ISOLATED variable. I hope that's OK. The nonexistent variable is: > 3/3: ':z:'/':z:' > 0: :a: is now, :z: is :z:, :b: is If it sprouts legs, I don't want to know > ------------------------ so if you want globals, no extra flags, just go up at level 0 and set them there; sensible, looks fine to me, on 1st pass :) > and on vanilla it outputs this: > > ------------------------ > 1: :a: is def, :z: is abcdefghijklmnop, :b: is abcdef ... > 1: :a: is toodels, :z: is ook! ook! banana!, :b: is If it sprouts > legs, I don't want to know > 0: :a: is toodels, :z: is ook! ook! banana!, :b: is If it sprouts > legs, I don't want to know > ------------------------ > > Now, about those bound vars, you were saying? Did you expect :a: to > end up like that after that alter-mod to :z:? > I didn't. me neither, I'd expect the former results for local/scoped vars; the latter is simply coherent with vars being globals. Check with missing xample as well. > And :b: also sees an interesting change, which isn't entirely sensible. indeed; I'd expect just 'If it ' > Also note that here is a prime example of the more profound error > checking done by GerH: alter isn't expected to have to act on a > nonexistent var, so GerH (correctly) yaks about it, if ever so softly > (not a trap, just a warning). vanilla just barges on. no, in vanilla :z: gets defined by the ISOLATE in :capture_func:, shouldn't throw an error. > Last but not least: note the use of the internal :_cd:, which is used sensible :) -- paolo ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H