Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables?

by premchai21 (Curate)
on Mar 28, 2003 at 19:02 UTC ( #246536=note: print w/replies, xml ) Need Help??


in reply to Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables?

Could you have an on-buffer-change hook of some sort that accesses a data structure keeping track of which variables were buffer-local to which buffers and swaps their values in and out appropriately?

That is, something like (quite untested):

sub onBufferChange { my ($from, $to) = @_; for my $scl (values $from->{locals}) { $$$scl[0] = $globalLocals{$$scl[0]}[1]; } for my $scl (values $to->{locals}) { exists $globalLocals{$$scl[0]} or $globalLocals{$$scl[0]} = [$$scl[0], $$$scl[0]]; $$$scl[0] = $$scl[1]; } }

I have the feeling I've missed the point...

  • Comment on Re: Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables?
  • Download Code

Replies are listed 'Best First'.
Re: Implementing (elisp-like) buffers in Perl 6: how to do buffer-localisation of arbitrary package variables?
by jonadab (Parson) on Mar 29, 2003 at 00:22 UTC

    ++

    I actually feel pretty stupid for not seeing that. It's quite simple, really: rather than making the current buffer a package variable on the buffer class, I just make it a method (that functions as an lvalue if need be; I'm pretty sure that's possible in Perl6) on the buffer class, and then I can do whatever symbol table changes I need to do. It makes changing buffers very frequently a little more inefficient, but it won't be a big deal unless you have a lot of buffer-local variables, and in that case it's worth it because you're really using the feature. And actually, it's probably not less efficient than making every variable lookup check for buffer-localness.

    I'm happy. Perl6 is going to be so cool. Here's looking forward to the next Apocalypse :-)


    for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://246536]
help
Chatterbox?
[LanX]: It seems that PHP's official docs use "closure" and "anonymous function" interchangeably, even though their closures don't capture surrounding state without using the 'use' language construct.
LanX explains much cargo bla ...
[Eily]: what? I thought PHP was known for its reliable and consistent behaviour and documentation!
[LanX]: ... and a lot of pseudo Perl experts
[Eily]: though honestly, I'm sure I have seen people use closure to mean anonysub for perl as well
[stonecolddevin]: good morning friends

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2018-02-23 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (304 votes). Check out past polls.

    Notices?