emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch: Syntax and Hard Newlines


From: Johan Bockgård
Subject: Re: Patch: Syntax and Hard Newlines
Date: Wed, 15 Nov 2006 16:47:28 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> or change byte-opt.el to mark the `propertize' function with
> `byte-optimize-pure-func' rather than with `side-effect-free'.

But then byte-compilation would change the semantics of `propertize'.

    -- Function: propertize string &rest properties
        This function returns a copy of STRING [...]
                                ^^^^

Actually, that is already the case for (at least) `concat':

    (progn
      (defun f () (concat "a" "b" "c"))
      (aset (f) 0 ?X)
      (f))

     =>  "abc"

    (progn
      (defun f () (concat "a" "b" "c"))
      (byte-compile 'f)
      (aset (f) 0 ?X)
      (f))

     =>  "Xbc"


    -- Function: concat &rest sequences
        This function returns a new string [...]

        The `concat' function always constructs a new string that
        is not `eq' to any existing string. [...]




While playing with this I found another bug.

This change 

    revision 2.143
    date: 2004-03-12 11:09:59 +0100;  author: rms;  state: Exp;  lines: +3 -2
    (byte-compile-get-constant): For strings, do compare text properties.

was made to fix a bug
(http://lists.gnu.org/archive/html/bug-gnu-emacs/2004-03/msg00080.html),
but it accidentally broke constant folding for strings entirely.

It replaced 

    (assoc ,const byte-compile-constants)

with

     (assoc-default ,const byte-compile-constants
                    'equal-including-properties nil)

However, unlike `assoc' which returns the matching cons,
`assoc-default' returns the cdr. In the code in question it is always
nil.

    (assoc-default "foo" '(("foo")) 'equal-including-properties nil)

    => nil

   (assoc "foo" '(("foo")))

    => ("foo")


(This should be trivial to fix.)

-- 
Johan Bockgård





reply via email to

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