From: John Atwood
Subject: how to read/write comments (semicolons & sharpsign verticle bar)?
Date: 
Message-ID: <7q40sv$2pe$1@news.NERO.NET>
I'm trying to use the pretty-printer, and want to keep comments,
would i after the readtable and add an entry to the  
*print-pprint-dispatch* table?  Anyone have any examples of this?
How would I support single and double semicolon conventions? 
Does the pretty-print already do this?



Thanks,


John Atwood
From: Kent M Pitman
Subject: Re: how to read/write comments (semicolons & sharpsign verticle bar)?
Date: 
Message-ID: <sfw7lmi5k9t.fsf@world.std.com>
·······@bronze.CS.ORST.EDU (John Atwood) writes:

> I'm trying to use the pretty-printer, and want to keep comments,
> would i after the readtable and add an entry to the  
> *print-pprint-dispatch* table?  Anyone have any examples of this?
> How would I support single and double semicolon conventions? 
> Does the pretty-print already do this?

There was recently an extended discussion on this matter.

It is, as I mentioned in another post, probably a bad idea.  Readmacros
don't get positional information about where they occur, for example;
what column, what line, etc.  Nor about what forms are to their left or
above them.  Making a comment come out in the right place is hard.  Consider:


  (foo) ;<-- this is foo
   ;^-- so is this

You are really using the wrong paradigm to try to handle comments at the
readmacor level, IMO.  You will end up asking 1,000,000 questions because
the representation will not match your goals and every kludge you come up
with to handle some part of the problem will create some new problem.

Also, the whole pprint facility has as an underlying assumption that the
forms it is printing are well-formed.  If you include comments and 
probably sharpsign conditionals and #. forms and the original form of
dotted pairs so you can tell (a . (b)) from (a b) even though they,
after reading, are identical, then you will have lots of objects that are
not what PPRINT expects to see.  for example, pprint is not prepared to
handle 
  (#+FOO FOO:SOMETHING #+BAR BAR:SOMETHING-ELSE ...)
if the FOO:SOMETHING has a special way of being pretty-printed since it
will see some #<YOUR-EXTENSIONS:SHARPSIGN-PLUS > thing as the car of the
list, not a symbol.  Presumably.  Further, it will get potentially confused
by this, too, depending on how you code it:
   (SETQ FOO #+FOO 3 #+BAR 4)

See my other post on this (before you separated the thread) for more 
remarks.  See also Deja News  (http://www.deja.com/home_ps.shtml)