<div dir="ltr">It sounds to me like the <div><br></div><div>FWIW, the arrows that you see when you mouse around the contents of the blue boxes in the upper-right corner are derived from information obtained post-macro expansion (this is happening continuously in the background in drracket). Probably that's the best way to get this information. That is, you can write your iU, etc. macros so they leave properties in the expanded output that say how to render the thing specially. That sounds straightforward to me. It would not appear immediately (just like the arrows don't appear immediately), tho. So if that's a killer, then you'd need to do something more complex.</div>
<div><br></div><div>The way editing would work sounds much more tricky so I would suggest that you start with something that is really dumb on the "recognize the thing" side -- just have something that recognizes specific regular expressions of even fixed strings and then play around with how editing would work, working directly with a text% object, and then later getting that working with a racket:text% object.</div>
<div><br></div><div style>hth,</div><div>Robby</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 5, 2013 at 8:42 AM, Tony Clark <span dir="ltr"><<a href="mailto:t.n.clark@mdx.ac.uk" target="_blank">t.n.clark@mdx.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for getting back to me on this.<br>
<br>
The kind of thing I had in mind was to be able to type:<br>
<div class="im"><br>
(iU (i n) (Person (index name i)))<br>
<br>
</div>as source code into Dr Racket. Once the closing parenthesis on the form was typed, the editor would recognise the form as special and redisplay it as $\bigcup_{i\in[0,n]} (Person (index name i))$. In principle, the format of the input could be flexible, for example:<br>
<br>
!(i n) (Person (index name i)))<br>
<br>
Could have the same effect if it would be more convenient to get the processing done via some character macro in the reader.<br>
<br>
In a super-duper ideal world, once recognised and displayed in the math-style with subscripts, the identifier names used in the subscript would be editable in-place (via some form of selection and/or mouse navigation). However, I think it would be acceptable for the projected form to revert to the AST text-representation when it is selected for editing.<br>
<br>
Regarding macro-expansion: I am not certain, but assume that the macro expansion occurs after the forms in a DrRacket pane have been fully read. Projectional Editors should ideally recognise the input and perform the conversion to the 'projected' output format in-place as the text is typed. I guess I could be completely wrong on that, in which case macro-expansion could help 'catch' the input form and convert to the output form (but would need to grab access to the underlying graphics for the editor surely?).<br>
<br>
I don't think that a separate window<%> object would be acceptable, it needs to integrate with the 'normal' editor as presented in DrRacket.<br>
<br>
-- Tony<br>
<br>
From: Robby Findler <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a><mailto:<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>>><br>
Date: Friday, 5 July 2013 14:26<br>
To: Tony Clark <<a href="mailto:t.n.clark@mdx.ac.uk">t.n.clark@mdx.ac.uk</a><mailto:<a href="mailto:t.n.clark@mdx.ac.uk">t.n.clark@mdx.ac.uk</a>>><br>
Cc: "<a href="mailto:users@racket-lang.org">users@racket-lang.org</a><mailto:<a href="mailto:users@racket-lang.org">users@racket-lang.org</a>>" <<a href="mailto:users@racket-lang.org">users@racket-lang.org</a><mailto:<a href="mailto:users@racket-lang.org">users@racket-lang.org</a>>><br>
Subject: Re: [racket] Projectional Editors<br>
<div class="im HOEnZb"><br>
I think DrRacket has all of the tools necessary to do what you're asking, but there is no convenient API for putting it all together. Depending on how you wanted it to look, I'd offer different suggestions on how to get started, I guess. For example, if you're happy with the projections being in a separate window<%> object, that'd be the easiest thing, I guess (and much of the work you'd do could be re-used if you wanted a different way to draw it, with a little bit of planning).<br>
<br>
Are you thinking of using the raw source code to get the projection, or are you planning to involve macro expansion?<br>
<br>
Robby<br>
<br>
<br>
</div><div class="HOEnZb"><div class="h5">On Fri, Jul 5, 2013 at 2:52 AM, Tony Clark <<a href="mailto:t.n.clark@mdx.ac.uk">t.n.clark@mdx.ac.uk</a><mailto:<a href="mailto:t.n.clark@mdx.ac.uk">t.n.clark@mdx.ac.uk</a>>> wrote:<br>
Dear All,<br>
<br>
I am implementing a language that involves patterns over sets. I am experimenting with an 'indexed set' pattern of the form:<br>
<br>
(iU (index-var limit-var) pattern …)<br>
<br>
Where pattern can include constants, (indexed) variables, (indexed) sets and terms. For example:<br>
<br>
(iU (i n) (Person (index name i)))<br>
<br>
Matches a set of terms:<br>
<br>
'((Person fred) (Person bert) (Person sally))<br>
<br>
To produce a binding environment:<br>
<br>
'((n . 2) (name-0 . fred) (name-1 . bert) (name-2 . sally))<br>
<br>
My question is whether DrRacket can be extended with 'projectional editing' features so that:<br>
<br>
(iU (i n) (Person (index name i)))<br>
<br>
When entered, is displayed using the equivalent of latex:<br>
<br>
$\bigcup_{i\in[0,n]} (Person (index name i))$<br>
<br>
A projectional editor (<a href="http://martinfowler.com/bliki/ProjectionalEditing.html" target="_blank">http://martinfowler.com/bliki/ProjectionalEditing.html</a>) works by representing the AST of a language and then providing the user with a view of the AST, thereby allowing fancy representations. Whether the user can interact with the fancy representation or has to work at the AST level depends on the projectional editor.<br>
<br>
I think DrRacket ought to be ideal for this kind of thing since: (a) we are essentially working on an AST already; (2) the editor appears to be programmable; (3) the GUI libraries allow easy dynamic creation of images that can be inserted into the editor.<br>
<br>
I looked at the reference for DrRacket Plugins, but encountered a large interface that I am unsure how to navigate.<br>
<br>
Thanks for any pointers.<br>
<br>
-- Tony<br>
<br>
<br>
<br>
---------------------------------------------------------------------------<br>
<br>
<br>
Please note that Middlesex University's preferred way of receiving all correspondence is via email in line with our Environmental Policy. All incoming post to Middlesex University is opened and scanned by our digital document handler, CDS, and then emailed to the recipient.<br>
<br>
If you do not want your correspondence to Middlesex University processed in this way please email the recipient directly. Parcels, couriered items and recorded delivery items will not be opened or scanned by CDS. There are items which are "exceptions" which will be opened by CDS but will not be scanned a full list of these can be obtained by contacting the University.<br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
<br>
<br>
<br>
---------------------------------------------------------------------------<br>
<br>
<br>
Please note that Middlesex University's preferred way of receiving all correspondence is via email in line with our Environmental Policy. All incoming post to Middlesex University is opened and scanned by our digital document handler, CDS, and then emailed to the recipient.<br>
<br>
If you do not want your correspondence to Middlesex University processed in this way please email the recipient directly. Parcels, couriered items and recorded delivery items will not be opened or scanned by CDS. There are items which are "exceptions" which will be opened by CDS but will not be scanned a full list of these can be obtained by contacting the University.<br>
<br>
</div></div></blockquote></div><br></div>