[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [External] : Re: Question about native compilation (bug?)
From: |
Eli Zaretskii |
Subject: |
Re: [External] : Re: Question about native compilation (bug?) |
Date: |
Thu, 27 Jul 2023 22:11:43 +0300 |
> From: Drew Adams <drew.adams@oracle.com>
> CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Thu, 27 Jul 2023 18:14:15 +0000
>
> > > What about my other questions, e.g. wrt fixing this?
> >
> > I haven't done any recent analysis, from what I remember it is not
> > easily fixable.
> >
> > That said I think is not worth of, redefining primitives is already
> > discouraged by the manual and dangerous (more on that later), doing it
> > with a different signature it's just kamikaze behavior.
> >
> > Note also that redefining primitives in Emacs is not only disincouraged,
> > but is really not guaranteed to work properly. The redefinition will
> > not take effect executing bytecode if the primitive has a dedicated
> > byteopcode and it will *not* take effect either for any call to the
> > primiteve done form C itself.
>
> I don't claim to understand all of that, e.g.
> primitives that do or don't have dedicated
> byteopcodes etc.
>
> The fact is that it does work for `read-buffer',
> except when native compilation is turned on.
If we ever decide to give read-buffer a dedicate bytecode op-code, it
will stop working. So applications using this are unreliable.
> The point is to have compatibility with what
> happens with Lisp source code.
>
> If this can't/won't be fixed, so be it. But it
> makes Elisp code with native compilation behave
> differently from Elisp code that's either source
> or byte-compiled.
By doing this you invoke "undefined behavior", whereby you cannot talk
about "different behavior" because the behavior is undefined.
> If this won't be fixed, or until it is, shouldn't
> such incompatibility be called out in the doc?
We already advise not to redefine existing functions:
Be careful not to redefine existing functions unintentionally.
‘defun’ redefines even primitive functions such as ‘car’ without
any hesitation or notification. Emacs does not prevent you from
doing this, because redefining a function is sometimes done
deliberately, and there is no way to distinguish deliberate
redefinition from unintentional redefinition.
> Even aside from imagining redefinitions, does
> it make sense for a source-code function call
> that passes N args to be changed to a call that
> passes N args plus M nil args? That's really
> what this is about, it seems to me: reproducing
> the actual call, as is, instead of adding
> explicit nil optional args. We don't do that
> with byte compilation, right? Why should we
> need to do it with native compilation?
Because native code runs natively, not by our interpreter, and thus
must have a fixed number of arguments.
- Question about native compilation (bug?), Drew Adams, 2023/07/26
- Re: Question about native compilation (bug?), Tassilo Horn, 2023/07/27
- Re: Question about native compilation (bug?), Andrea Corallo, 2023/07/27
- RE: [External] : Re: Question about native compilation (bug?), Drew Adams, 2023/07/27
- Re: [External] : Re: Question about native compilation (bug?), Andrea Corallo, 2023/07/27
- RE: [External] : Re: Question about native compilation (bug?), Drew Adams, 2023/07/27
- Re: [External] : Re: Question about native compilation (bug?), Andrea Corallo, 2023/07/27
- RE: [External] : Re: Question about native compilation (bug?), Drew Adams, 2023/07/27
- Re: [External] : Re: Question about native compilation (bug?), Andrea Corallo, 2023/07/27
- Re: [External] : Re: Question about native compilation (bug?),
Eli Zaretskii <=