all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
       [not found] ` <20220114200316.CB79BC0DA30@vcs2.savannah.gnu.org>
@ 2022-01-17 13:38   ` Robert Pluim
  2022-01-17 17:23     ` Philipp Stephani
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2022-01-17 13:38 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

>>>>> On Fri, 14 Jan 2022 15:03:16 -0500 (EST), Philipp Stephani <p.stephani2@gmail.com> said:

    Philipp> branch: master
    Philipp> commit 64109fcae710a372bf7690e2da461ab71ca78dcd
    Philipp> Author: Philipp Stephani <phst@google.com>
    Philipp> Commit: Philipp Stephani <phst@google.com>

    Philipp>     indent-for-tab-command: Deal with large point or modiff values.
    
    Philipp>     * lisp/indent.el (indent-for-tab-command): Don't use 'eq' to compare
    Philipp>     integers that aren't guaranteed to be fixnums.
    Philipp> ---
    Philipp>  lisp/indent.el | 4 ++--
    Philipp>  1 file changed, 2 insertions(+), 2 deletions(-)

    Philipp> diff --git a/lisp/indent.el b/lisp/indent.el
    Philipp> index 8dc4c31f13..ad6fd899c5 100644
    Philipp> --- a/lisp/indent.el
    Philipp> +++ b/lisp/indent.el
    Philipp> @@ -182,8 +182,8 @@ prefix argument is ignored."
    Philipp>        (cond
    Philipp>         ;; If the text was already indented right, try completion.
    Philipp>         ((and (eq tab-always-indent 'complete)
    Philipp> -             (eq old-point (point))
    Philipp> -             (eq old-tick (buffer-chars-modified-tick))
    Philipp> +             (eql old-point (point))
    Philipp> +             (eql old-tick (buffer-chars-modified-tick))
    Philipp>               (or (null tab-first-completion)
    Philipp>                   (eq last-command this-command)
    Philipp>                   (and (equal tab-first-completion 'eol)

You could use '=' here, no, just to emphasise the point that these are integers?

Robert
-- 



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

* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
  2022-01-17 13:38   ` master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values Robert Pluim
@ 2022-01-17 17:23     ` Philipp Stephani
  2022-01-17 17:29       ` Robert Pluim
  2022-01-17 19:55       ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Philipp Stephani @ 2022-01-17 17:23 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Philipp Stephani, Emacs developers

Am Mo., 17. Jan. 2022 um 15:27 Uhr schrieb Robert Pluim <rpluim@gmail.com>:
>
> >>>>> On Fri, 14 Jan 2022 15:03:16 -0500 (EST), Philipp Stephani <p.stephani2@gmail.com> said:
>
>     Philipp> branch: master
>     Philipp> commit 64109fcae710a372bf7690e2da461ab71ca78dcd
>     Philipp> Author: Philipp Stephani <phst@google.com>
>     Philipp> Commit: Philipp Stephani <phst@google.com>
>
>     Philipp>     indent-for-tab-command: Deal with large point or modiff values.
>
>     Philipp>     * lisp/indent.el (indent-for-tab-command): Don't use 'eq' to compare
>     Philipp>     integers that aren't guaranteed to be fixnums.
>     Philipp> ---
>     Philipp>  lisp/indent.el | 4 ++--
>     Philipp>  1 file changed, 2 insertions(+), 2 deletions(-)
>
>     Philipp> diff --git a/lisp/indent.el b/lisp/indent.el
>     Philipp> index 8dc4c31f13..ad6fd899c5 100644
>     Philipp> --- a/lisp/indent.el
>     Philipp> +++ b/lisp/indent.el
>     Philipp> @@ -182,8 +182,8 @@ prefix argument is ignored."
>     Philipp>        (cond
>     Philipp>         ;; If the text was already indented right, try completion.
>     Philipp>         ((and (eq tab-always-indent 'complete)
>     Philipp> -             (eq old-point (point))
>     Philipp> -             (eq old-tick (buffer-chars-modified-tick))
>     Philipp> +             (eql old-point (point))
>     Philipp> +             (eql old-tick (buffer-chars-modified-tick))
>     Philipp>               (or (null tab-first-completion)
>     Philipp>                   (eq last-command this-command)
>     Philipp>                   (and (equal tab-first-completion 'eol)
>
> You could use '=' here, no, just to emphasise the point that these are integers?

Yeah, they have identical semantics for integers. I tend to prefer eql
since its overall semantics are simpler (but the manual disagrees and
says that = should be preferred).



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

* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
  2022-01-17 17:23     ` Philipp Stephani
@ 2022-01-17 17:29       ` Robert Pluim
  2022-01-17 19:55       ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Pluim @ 2022-01-17 17:29 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Philipp Stephani, Emacs developers

>>>>> On Mon, 17 Jan 2022 18:23:07 +0100, Philipp Stephani <p.stephani2@gmail.com> said:
    >> You could use '=' here, no, just to emphasise the point that these are integers?

    Philipp> Yeah, they have identical semantics for integers. I tend to prefer eql
    Philipp> since its overall semantics are simpler (but the manual disagrees and
    Philipp> says that = should be preferred).

Iʼm a simple man: I can retain the difference between `eq' and
'equal', but throwing `eql' into the mix is just too much :-)

Robert
-- 



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

* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
  2022-01-17 17:23     ` Philipp Stephani
  2022-01-17 17:29       ` Robert Pluim
@ 2022-01-17 19:55       ` Stefan Monnier
  2022-01-17 21:35         ` Mattias Engdegård
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2022-01-17 19:55 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Robert Pluim, Philipp Stephani, Emacs developers

>> You could use '=' here, no, just to emphasise the point that these are integers?
> Yeah, they have identical semantics for integers. I tend to prefer eql
> since its overall semantics are simpler

Agreed.  `=` can signal an error and obeys the NaN corner cases as
dictated by IEEE so I usually prefer `eql`.

> (but the manual disagrees and says that = should be preferred).

Can't agree on everything.

> Iʼm a simple man: I can retain the difference between `eq' and
> 'equal', but throwing `eql' into the mix is just too much :-)

It's easy: just always use `eql` instead of `eq`.
They only differ in two cases:
- `eql` gives you the answer you expected and `eq` gives an answer that
  baffles you.
- your code is *really* naughty.
`eq` can be marginally faster, but the difference is so small that it's
only noticeable when it's called from C in a tight loop, like maybe when
comparing `memq` and `memql` but not when calling `eq` vs `eql` from
ELisp where the actual overhead of interpreting the byte code is large
enough to dwarf the difference of the execution of the op itself.


        Stefan




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

* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
  2022-01-17 19:55       ` Stefan Monnier
@ 2022-01-17 21:35         ` Mattias Engdegård
  2022-01-17 22:25           ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2022-01-17 21:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Philipp Stephani, Robert Pluim, Emacs developers

17 jan. 2022 kl. 20.55 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

> `eq` can be marginally faster, but the difference is so small that it's
> only noticeable when it's called from C in a tight loop, like maybe when
> comparing `memq` and `memql` but not when calling `eq` vs `eql` from
> ELisp where the actual overhead of interpreting the byte code is large
> enough to dwarf the difference of the execution of the op itself.

That's not quite true; the fact that `eq` has a byte-code and `eql` doesn't can be quite noticeable. Consider this very reasonable function for finding an element in a vector:

(defun vmemq (x v)
  (let ((n (length v))
        (i 0))
    (while (and (< i n) (not (eq (aref v i) x)))
      (setq i (1+ i)))
    (and (< i n) i)))

Replace `eq` with `eql` and execution time goes up 76 %, which is substantial by any measure. (Emacs 28, on vectors 1000 elements long.)




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

* Re: master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values.
  2022-01-17 21:35         ` Mattias Engdegård
@ 2022-01-17 22:25           ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2022-01-17 22:25 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Philipp Stephani, Robert Pluim, Emacs developers

> That's not quite true; the fact that `eq` has a byte-code and `eql`
> doesn't can be quite noticeable. Consider this very reasonable
> function for finding an element in a vector:

Oh, I forgot that detail (my measurements were on my local branch where
I made `eq` behave like `eql` and where they hence both have (the same)
bytecode).


        Stefan




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

end of thread, other threads:[~2022-01-17 22:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <164219059635.16941.2631797019964844711@vcs2.savannah.gnu.org>
     [not found] ` <20220114200316.CB79BC0DA30@vcs2.savannah.gnu.org>
2022-01-17 13:38   ` master 64109fcae7 2/3: indent-for-tab-command: Deal with large point or modiff values Robert Pluim
2022-01-17 17:23     ` Philipp Stephani
2022-01-17 17:29       ` Robert Pluim
2022-01-17 19:55       ` Stefan Monnier
2022-01-17 21:35         ` Mattias Engdegård
2022-01-17 22:25           ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.