[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PRINT methods
- To: Ram@YALE.ARPA
- Subject: Re: PRINT methods
- From: Norman Adams <Adams@YALE.ARPA>
- Date: Sat ,30 Mar 85 04:35:43 EDT
- Cc: T-Discussion@YALE.ARPA
- In-reply-to: Ashwin Ram <Ram>, Fri, 29 Mar 85 23:20:15 EST
- Invalid-addresses: RINGTDISCUSSION (?Unknown or ambiguous person, mailing list, or local user)
Contents: (a) a new kind of PRINT operation.
(b) a convention for using PRINT, PRETTY-PRINT, and the new operation.
------------------------------------------------
...
Notice that neither PRINT nor PRETTY-PRINT prints the object in a format
which would restore the object on being re-read.
...
The contract of READ and PRINT is that they are inverses. There are
some things which are hard to PRINT (READ) in a READ-able (PRINT-able) way.
PRINT punts on structures and procedures by using the #{...} notation.
(define (foo x y)
(list x y) )
(PRETTY-PRINT foo (terminal-output))
==> (LAMBDA (X Y)
(LIST X Y) )
...
(PRINT-READABLE foo (terminal-output))
==> (DEFINE (FOO X Y)
(LIST X Y) )
I think there is more to doing this than you have realized.
There are a few subtleties to printing procedures that you do not
mention here. A procedure is code and an environment. To be able
to read a procedure, you would have to represent its environment
somehow. Consider:
(let ((z 1))
(define (foo x y) (list x y z))
)
as opposed to
(let ((z 2))
(define (foo x y) (list x y z))
)
or
(let ((list +))
(define (foo x y) (list x y z))
)
There are similar problems with structures. (One of the slots might
be a procedure, for example). Side-effects make things even more
complicated. It is possible to write a semi-general structure
dumper given restrictions on what is in the slots (indeed we
have one for the compiler), but it is not as easy as your message
seems to imply.
-Norman
-------