Re: Destructive Functions
- From: Paul Foley <see@xxxxxxxxxxxxx> (http://public.xdi.org/=pf)
- Date: Sat, 24 Dec 2005 21:54:33 +1300
On 24 Dec 2005 01:24:07 -0500, jayessay wrote:
> Barry Margolin <barmar@xxxxxxxxxxxx> writes:
>> > I believe you are thinking of coalescing here. Literals (objects) in
>> > COMPILEd code are required to reference (as in eql) the literals
>> > (objects) in the source code. So, if a literal in the source is
>> > already "coalesced", say by the reader, then the COMPILEd code will
>> > refer to only one such object for that literal. So, the thrust of
>> > what Pascal is saying here still stands.
>>
>> The reader is not allowed to coalesce constants, AFAIK. Only the
>> file-compiler can.
> Hence the "scare-quotes". To coalesce literals X and Y from some
> source code would mean that they must start out not eql, but their
> corresponding objects in the compiled code are eql. But if (eql X Y)
> is true, then their corresponding objects in the compiled code of a
> COMPILE must also be eql. So, if '(1 2 3) shows up as a literal in
> two pieces of some source, and these map to the same object, then they
The literal '(1 2 3) appearing twice (in two pieces of source) can't
"map to the same object", since the list has to be built up at read
time. (Unless you mean something like using #n# notation to put the
same object in two places)
>> in-core compiler seems like a wart. As a result, it's likely that the
>> following simple function will behave differently depending on whether
>> it's compiled by COMPILE or COMPILE-FILE:
>>
>> (defun compile-file-p ()
>> "Should return NIL when COMPILEd, may return T when COMPILE-FILEd."
>> (eq '(nil) '(nil)))
> Interesting. I would have thought otherwise. Here's some data on this:
> CL-USER(1): (defun foo () (eq '(1 2 3) '(1 2 3)))
> FOO
> CL-USER(2): (foo)
> NIL ;; !!! a bit odd to me.
Evaluating (QUOTE x) returns x -- the very same value that occurs in
the QUOTE form, not some "similar" value. The list (1 2 3) in the
first QUOTE form is obviously a different list than the one in the
second QUOTE form, so they /can't/ be EQ.
> CL-USER(3): (compile 'foo)
> FOO
> NIL
> NIL
> CL-USER(4): (foo)
> T ;;; More like it to my mind, but still odd given the interpreter results
Eh? What implementation is this? I'd call that a bug.
--
Quid enim est stultius quam incerta pro certis habere, falsa pro veris?
-- Cicero
(setq reply-to
(concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))
.
- Follow-Ups:
- Re: Destructive Functions
- From: jayessay
- Re: Destructive Functions
- From: Duane Rettig
- Re: Destructive Functions
- From: Pascal Bourguignon
- Re: Destructive Functions
- References:
- Destructive Functions
- From: diviam
- Re: Destructive Functions
- From: Pascal Costanza
- Re: Destructive Functions
- From: Paul Foley
- Re: Destructive Functions
- From: jayessay
- Re: Destructive Functions
- From: Barry Margolin
- Re: Destructive Functions
- From: jayessay
- Destructive Functions
- Prev by Date: Re: Do I have to be an expert to get performance: CL versus Perl
- Next by Date: Re: Destructive Functions
- Previous by thread: Re: Destructive Functions
- Next by thread: Re: Destructive Functions
- Index(es):
Relevant Pages
|