all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: acorallo@gnu.org, emacs-devel@gnu.org
Subject: Re: [External] : Re: Question about native compilation (bug?)
Date: Thu, 27 Jul 2023 22:11:43 +0300	[thread overview]
Message-ID: <83bkfxkw40.fsf@gnu.org> (raw)
In-Reply-To: <SJ0PR10MB5488F65B1546166F243D1E05F301A@SJ0PR10MB5488.namprd10.prod.outlook.com> (message from Drew Adams on Thu, 27 Jul 2023 18:14:15 +0000)

> 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.



      parent reply	other threads:[~2023-07-27 19:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26 21:32 Question about native compilation (bug?) Drew Adams
2023-07-27  4:45 ` Tassilo Horn
2023-07-27 15:25   ` [External] : " Drew Adams
2023-07-27  9:53 ` Andrea Corallo
2023-07-27 14:37   ` [External] : " Drew Adams
2023-07-27 16:15     ` Andrea Corallo
2023-07-27 17:05       ` Drew Adams
2023-07-27 17:51         ` Andrea Corallo
2023-07-27 18:14           ` Drew Adams
2023-07-27 18:38             ` Andrea Corallo
2023-07-27 19:11             ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bkfxkw40.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acorallo@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.