unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Andrea Corallo <acorallo@gnu.org>
Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>,
	monnier@iro.umontreal.ca, mattias.engdegard@gmail.com,
	stefankangas@gmail.com
Subject: Re: Introducing 'safety' compilation parameter
Date: Tue, 7 May 2024 12:01:33 +0000	[thread overview]
Message-ID: <ZjoYHQ5cHPqpKInW@ACM> (raw)
In-Reply-To: <yp18r0lzz41.fsf@fencepost.gnu.org>

Hello, Andrea.

On Tue, May 07, 2024 at 06:37:50 -0400, Andrea Corallo wrote:
> Hello,

> I've put in scratch/comp-safety a branch which introduces 'safety' as
> compilation parameter.

I'm against this; see below.

> 'safety' can be used similarly to 'native-comp-speed' both as a global
> variable to influence compilation both as a function declaration.

> 'safety' justification of existence is ATM being able to control the
> undefined behaviour being created when function type declaration added
> by the user is not correct.

How is this undefined behaviour?  Lisp is a dynamically typed language.
If a function type declaration is added, this can only be advisory.  If
it is incorrect, then by the specification of (Emacs) Lisp, the code
generated must still correctly handle its arguments and run.

> ATM we can have two values:

> 1 Emitted code is generated in a safe matter even if function types are
> miss-declared.

I'm in favour of this remaining.

> 0 Emitted code can misbehave or crash Emacs if function declarations are
> not correct and the function is native compiled (@pxref{Native
> Compilation}).

I'm in favour of this not being merged.  Crashing Emacs for valid (or
even invalid) Lisp should not be an option.

> 1 is ATM the default.

I see this change as one more boil-the-frog-slowly step towards turning
Emacs Lisp into a statically typed language.  If this change gets merged
into master, how long will it be until these function declarations
become first common, then usual, then all but universal?  It that were
to happen, it would be, in my opinion, a net loss to Emacs.

Why do we need this change at all?  It may generate somewhat faster (or
smaller) code, but isn't native compiled Lisp already fast enough,
particularly on a modern machine?

> I didn't want to give safety a prefix (byte- or comp-) as I believe we
> should extend safety in the future with a value to have the byte
> compiler generates runtime type checks to verify the declred types.
> OTOH this is creating a warning for a missing prefix, not sure what's
> the best way to fix this (give it a prefix or silence the compiler if
> possible).

> Also I added some doc for the declaration, but didn't kwnow where in the
> manual the documention for the variable should go as now it has effect
> only for the native compiler.  Should I document it under
> "Native-Compilation Variables" for now?

> Thanks

>   Andrea

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2024-05-07 12:01 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07 10:37 Introducing 'safety' compilation parameter Andrea Corallo
2024-05-07 12:01 ` Alan Mackenzie [this message]
2024-05-07 13:15   ` Eli Zaretskii
2024-05-07 16:07     ` Drifting towards a statically typed Emacs Lisp. [Was: Introducing 'safety' compilation parameter] Alan Mackenzie
2024-05-07 17:06       ` Andrea Corallo
2024-05-07 23:37         ` Emanuel Berg
2024-05-07 18:00       ` Eli Zaretskii
2024-05-08  0:14         ` Emanuel Berg
2024-05-07 23:29       ` Emanuel Berg
2024-05-09 23:52       ` Richard Stallman
2024-05-10  6:31         ` Eli Zaretskii
2024-05-07 16:37   ` Introducing 'safety' compilation parameter Tomas Hlavaty
2024-05-07 16:54   ` Andrea Corallo
2024-05-07 23:42     ` Emanuel Berg
2024-05-07 14:56 ` Stefan Monnier
2024-05-07 16:13   ` Andrea Corallo
2024-05-10 17:58     ` Andrea Corallo
2024-05-13  2:29       ` Stefan Monnier
2024-05-13 18:59         ` Eli Zaretskii
2024-05-13 21:12           ` Andrea Corallo
2024-05-14  6:11             ` Eli Zaretskii
2024-05-09  8:40 ` Eli Zaretskii
2024-05-10  7:47   ` Andrea Corallo
2024-05-10 10:17     ` Eli Zaretskii
2024-05-10 11:42       ` Andrea Corallo
2024-05-10 15:10         ` Eli Zaretskii
2024-05-10 18:02   ` Andrea Corallo
2024-05-10 18:05     ` Andrea Corallo
2024-05-09  9:19 ` Gerd Möllmann
2024-05-10  7:58   ` Andrea Corallo
2024-05-10  8:09     ` Gerd Möllmann
2024-05-10  8:19       ` Andrea Corallo
2024-05-10 14:00     ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=ZjoYHQ5cHPqpKInW@ACM \
    --to=acm@muc.de \
    --cc=acorallo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=mattias.engdegard@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).