[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: byte-code optimizations

From: Paul Pogonyshev
Subject: Re: byte-code optimizations
Date: Wed, 22 Sep 2004 01:25:03 -0200
User-agent: KMail/1.4.3

Stefan wrote:

> >> However, there is still the question of whether we should
> >> change the standard defsubst to work the way defsubst* does.
> >
> > Maybe we can even use `defmacro' for `caar' and friends.  Since
> > they evaluate their lone argument only once, there must not be
> > any problems, right?
> Just think of (mapcar 'caar x)


> > If this (or `defsubst*') works, I'll investigate whether this
> > byte-code optimization gives any improvement after such a change.
> What defsubst* does is treat the argument as a kind of "lexically scoped"
> variable, but only in very limited ways.  I.e. the
>         (defsubst* caar (x) (car (car x)))
> will expand:
>         (caar y)  =>  (car (car y))
>         (caar (f y)) => (let ((x (f y))) ..cl-gunk.. (car (car x)))
> [ The cl-gunk is stuff added by CL for CL such as a `catch' statement. ]
> If you ignore the nasty cl-gunk, I think the resulting optimization is
> similar to what we get, except it works in a few more cases.
> E.g. it'll expand
>      (defsubst* foo (x) (symbol-value x))
>      (foo y) => (symbol-value y)
> whereas our optimization won't be able to do that because it can't assume
> a "somewhat lexically scoped" semantics.

Then byte-code optimization probably has only one advantage: it works
for normal `let' bindings too.  Probably not a particularly strong
advantage, though, as there must not be many so simple `let's around.

Will replacing `defsubst' definition with `defsubst*' or something
similar be visible from ``outside?''  Or, on a smaller scale, will
redefining `caar' and friends with `defsubst*' be?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]