Re: circumflex/caret

Paolo <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <20090225162356.GA1964@localhost>
On Wed, Feb 25, 2009 at 09:54:18AM -0500, Bill Yerazunis wrote:
> 
>   isolate (:a:) /Foo!/        # a is of global scope
>   call /:capture_func:/
>   output /:a: is :*:a:\n/
> 
>   :capture_func:
>   isolate (:z:) /abcdefghijklmnop/           # make :z: be local
>   match [:z:] /...(...).../  ( :: :a: )      # capture :a: into :z:
>   return
> 
> Now, :a: is attached to the 4th through 6th characters of :z: - but
> :z: is now _going away_.  So, what does :a: have?

I tend to like/think of _bounded_ vars as always locally scoped, thus
you'd need to do something like

  return /:*:a:/

> 
> Second question: are these scoped variables "dynamic" or "static" -
> that is, if I call a function with a locally scoped variable a second
> time, what is the value of a locally scoped variable?  Is it retained
> between calls (i.e. "static", as in C), or is the locally scoped
> variable reinitialized from scratch (so DEFAULT values values will

the latter, they vanish on return, unless explicitly declared like in C, eg

  isolate <static> (:a:) /blop/

> Third question: if it's really scoped, then there should be a way
> to create that local variable as an overlay, so it _keeps_ it's
> value on return, like this
> 
>    isolate (:a:) /foo/     
>    call /:capture_func:
>    output /:*:a:/         # should be back to /foo/

yep, I'd expect that.


> This drove me to consider that perhaps we needed four different waus
> for a variable to be created:
> 
>    isolate   - global scope

  isolate <global|static>
  
>    dynamic   - local scope, state lost on RETURN

  plain ISOLATE
  
>    static    - local scope, retained state

uh? local to what? like in C? whatever, I'd go for

  isolate <static>

>    match     - global by default, but will flow with dynamic or static.

local by default ;)

> In which case, doing a DYNAMIC or STATIC on a MATCHed variable
> does... what?  Do they create local overlays, in which case the old
> (MATCHed) value is restored on RETURN, or does it change the type of
> variable so they're erased (for dynamic) or hidden (for static) on
> return?
> 
> And if it's a MATCH captured variable, are changes made while in the 
> subroutine kept in the outer variable, or rolled back on RETURN?

looks to me that with MATCH'd vars as local things get simpler: all 
bindings vanish on RETURN, except if bounded vars have been ISOLATE'd
before the call.

Need quite some further thinking though ... also wrt memory footprint:
should a called routine setup its own full buffers for local vars? then
the thing may get quite memory-demanding.

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.