From: Scott D. Anderson
Subject: Re: 2 simple commonlisp questions
Date: 
Message-ID: <ANDERSON.95Apr5105837@earhart.cs.umass.edu>
In article <··········@nkosi.well.com> ····@well.sf.ca.us (Amy Caplan) writes:

> Two simple questions:
> 
> 1. If one does (declare (inline func)), is this only applicable to the
> current file / can an inline declaration *ever* have any effect across
> files?

Yes, it can.  As long as the compiler knows that FUNC is supposed to be inline
and it has access to FUNC's source code, it can inline it.  However, compilers
are also allowed to ignore this declaration.   

> 2. If there are some objects (e.g. structures with arrays as members)
> in memory, is there a way of printing them to disk and later reading
> back equivalent things?  [I tried setting *print-array* to true]

Yes, this is possible.  You also need to be sure your structure printing is
re-readable, but it is by default.  Consider the following transcript, where I
used a string instead of a file, but the principle is the same.


CL-USER 1 > (defstruct foo a b)
FOO

CL-USER 2 > (setf *print-array* t)
T

CL-USER 3 > (setf x (make-foo :a (make-array 5 :initial-contents '(a b c d e))))
#S(FOO A #(A B C D E) B NIL)

CL-USER 4 > (setf s (with-output-to-string (out) (print x out)))
"
#S(FOO A #(A B C D E) B NIL) "

CL-USER 5 > (read-from-string s)
#S(FOO A #(A B C D E) B NIL)
30

CL-USER 6 > (equalp * x)
T

CL-USER 7 > (eq ** x)
NIL

CL-USER 8 > 

> 
> [I checked the faq index for both of these topics]

Thank you!

Scott D. Anderson
········@cs.umass.edu
From: k p c
Subject: Re: 2 simple commonlisp questions
Date: 
Message-ID: <1995Apr12.034033.2583@ptolemy-ethernet.arc.nasa.gov>
Quoth ········@earhart.cs.umass.edu (Scott D. Anderson):
> > 2. If there are some objects (e.g. structures with arrays as members)
> > in memory, is there a way of printing them to disk and later reading
> > back equivalent things?  [I tried setting *print-array* to true]

> CL-USER 4 > (setf s (with-output-to-string (out) (print x out)))

Also, (with-standard-io-syntax) is sometimes useful to avoid
unexpected behavior.

P.S.  Note that in my copy of CLTL2, at least, the examples on page
567 are wrong!

USER(8): (with-standard-io-syntax (princ *read-eval*))
T
T
USER(9): (let ((*read-eval* nil)) (with-standard-io-syntax (princ *read-eval*)))
T
T

---
···@ptolemy.arc.nasa.gov.  AI, multidisciplinary neuroethology, info filtering.