[plt-scheme] snips, snip-classes, and snippy questions.

From: Jordan Johnson (jmj at soe.ucsc.edu)
Date: Mon Jun 19 23:42:32 EDT 2006

On Jun 15, 2006, at 9:46 AM, Matthew Flatt wrote:

> At Thu, 15 Jun 2006 08:52:08 -0700, Jordan Johnson wrote:
>> I understand from the MrEd docs that, by overring read, a subclass of
>> snip-class% tells how to handle the decoding of a snip that's stored
>> in encoded form.  Where and how does the ENcoding happen?
> When an editor<%>'s content is written to a stream, it calls the
> `write' methods of its snips. When an editor's content is read from a
> stream, it calls the `read' methods of classes named in the head of  
> the
> stream.

Thanks; I should've noticed that.  It would be worth including in the  
docs (perhaps under ``Encoding Snips'') what you've said explicitly  
above (and also cross-referencing snip%'s `write' from snip-class%'s  

>> ... I'm working with compound data structures (basically a graph  
>> of structs...) whose parts will be viewed in several different  
>> ways through several different interfaces...
> I'm not sure I understand, but it sounds like a snip is merely a view
> on some model, and one model can have multiple views. In that case, it
> seems like the model needs to be saved somehow in the header of the
> editor's encoded form, and then the encoded form of a snip needs to
> refer to that model part for which it's a view.

Yes, this is what's going on, essentially.  I've worked out a  
solution based on your suggestion.

Now, I have at least two contexts in which I'll be viewing these  
snips:  a graph-pasteboard% showing their relationships, and one or  
more text%s where some of them are part of a document,  
independently.  Their appearance depends on the editor.  (A small tag  
with a short label in the graph, a box with full text in the text  
editor.)  It looks like I could accomplish this by checking the type of
	(send (send mysnip get-admin) get-editor)
-- will this give me what I want, reliably? (And is it the most  
direct, logical way?)

Thanks again!


Posted on the users mailing list.