unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* pathological byte-compilation
@ 2002-06-25  1:26 Stefan Monnier
  2002-06-25  1:51 ` Miles Bader
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2002-06-25  1:26 UTC (permalink / raw)



CL used to define `values' as an alias to `list'.
It has been changed (end of last year) to

	(defsubst values (&rest values)
	  (apply 'list values))

This has the "interesting" side-effect that compiling the function
(defun foo () (values 1)) results in the following byte-code:

	byte code for foo:
	  args: nil
	0	constant  1
	1	list1	  
	2	varbind	  values
	3	constant  apply
	4	constant  list
	5	varref	  values
	6	call	  2
	7	unbind	  1
	8	return	  

in other words, the same result as if we had compiled
(defun foo () (let ((values (list 1))) (apply 'list values)))


	Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pathological byte-compilation
  2002-06-25  1:26 pathological byte-compilation Stefan Monnier
@ 2002-06-25  1:51 ` Miles Bader
  2002-06-25 23:32   ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Miles Bader @ 2002-06-25  1:51 UTC (permalink / raw)
  Cc: emacs-devel

"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> 	(defsubst values (&rest values)
> 	  (apply 'list values))
>
> in other words, the same result as if we had compiled
> (defun foo () (let ((values (list 1))) (apply 'list values)))

Of course, part of the problem is that defsubst is rather pathetic, in
that it retains the argument bindings no matter what.

A very long time ago I wrote an elisp function that analyzes `let' forms
and rewrites them to eliminate as many bindings as possible (e.g., when
it can substitute a variable's initialization value in the places where
the variable is used, without changing any side-effects).

That transformation assumed a `lexical style' use of `let', which isn't
something you can do generally, but in the case of defsubst, I think it
would probably be safe to say that argument bindings are not guaranteed
to be visible (via dynamic binding) in functions called from defsubt
body.

Such an optimization might greatly improve the results of using defsubst...

-Miles
-- 
.Numeric stability is probably not all that important when you're guessing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pathological byte-compilation
  2002-06-25  1:51 ` Miles Bader
@ 2002-06-25 23:32   ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2002-06-25 23:32 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

    That transformation assumed a `lexical style' use of `let', which isn't
    something you can do generally, but in the case of defsubst, I think it
    would probably be safe to say that argument bindings are not guaranteed
    to be visible (via dynamic binding) in functions called from defsubt
    body.

I hesitate to agree with this.  However, in many defsubsts only
primitives will be called.  It should be possible to determine that
nothing called from the defsubst will ever look at variable bindings.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-25 23:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-25  1:26 pathological byte-compilation Stefan Monnier
2002-06-25  1:51 ` Miles Bader
2002-06-25 23:32   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).