Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I've been thinking for a really long time that my dream language would have a lot of the features of Perl (hashes, fexible syntax, and so forth) and certain key features of other languages, most especially the object model from Inform and buffers (and the companion features that make them useful, such as markers and a standard library of functions to manipulate them) from Emacs lisp.

With me so far? Okay, so I've been reading the Apocalypse articles, and while the objects in Perl6 may not be quite exactly like the ones in Inform, they're going to be so much closer than the Perl 5 object model that they'll probably do. But that leaves buffers...

So I was thinking, hey, with this nice flexible object model, could we implement buffers in Perl6 as a module and throw it on CPAN? So I started thinking about how that would work...

A buffer, obviously, would be an object. The text it would store in some member data structure or another, and then it would also store other state, like string properties, a list of markers, metadata that applies to the whole buffer (filename if any, EOL mode, major mode, and so forth). So far so good. Markers are pretty easy, as long as all changes to the textual contents of the buffer go through methods on the buffer class, which have access to the buffer's list of all markers on the buffer. (Markers are their own class, of course, and know what buffer they point to as well as where, and moving them to point elsewhere goes through a member function that checks things like taking them off the old buffer's list if you point them into a new buffer.)

So, a class for buffers, a class for markers, ...

So far so good; I think all that could be easy enough to implement (though it would be a fairly large project, but also highly worth doing), but I ran into trouble when I started to think about making variables buffer-local. For buffers to be as useful as they are in elisp, it needs to be possible to give any package variable (from any package) a buffer-local value that applies whenever a certain buffer is the current buffer. (The current buffer presumably would be an important package var maintained by the buffers package.) And if a variable is buffer-local to the current buffer, then any assignments to it alter the buffer-local value, unless explicit steps are taken to set the default (global) value.

I thought about the syntactic warpage that the Apocalypse articles keep talking about, but I don't think any amount of syntax can accomplish this, because it's a semantic thing: *anything* that either retrieves or changes the value of any variable needs to check first to see if it's buffer-local to the current buffer (unless the variable is either lexically scoped or temporized, in which case those values take precedence).

So what I want to ask the monks (especially those who know more about Perl6 than I do) is, will it be possible via some other mechanism I don't know about or don't understand to do this as a module (or perhaps as a pragma or whatever -- I'm a little fuzzy on some of those distinctions) without having it in the core language? If so, approximately how?

Oh, and if not, how would we go about raising the issue now (while Perl6 is still set in Jello, rather than marble)? I'd really like to have a mechanism for this, because... well, it would just make for some very cool abilities. And to wait for Perl7 would be torment :-)


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$/}

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found