all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Markus Triska <triska@metalevel.at>
To: 23963@debbugs.gnu.org
Subject: bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect
Date: Wed, 13 Jul 2016 08:28:45 +0200	[thread overview]
Message-ID: <m2d1mif3vm.fsf@metalevel.at> (raw)


The manual entry of `unwind-protect' shows an example whose essence is:

    (unwind-protect
        (progn
          (setq process (ftp-...))
          ;; use process
      (delete-process process))

It adds the following important explanation:

    This example has a small [sic] bug: if the user types `C-g' to quit,
    and the quit happens immediately after the function `ftp-...'
    returns but before the variable `process' is set, *the process will
    not be killed*. There is no easy way to fix this bug, but at least
    it is very unlikely.

Would it be good to make such resource leak *impossible* instead? This
seems quite desirable and could be done with a complementing primitive.

Please consider a new primitive `setup-unwind-protect' with 3 arguments:

    1. SETUPFORM, called in such a way that it *cannot be interrupted*
    2. BODYFORM, like in unwind-protect, called after SETUPFORM
    3. UNWINDFORMS, like in unwind-protect

With this primitive, we could write the example above as:

    (setup-unwind-protect
        (setq process (ftp-...))
     (progn
       ;; use process ...
     (delete-process process))

Please consider adding such a construct to Emacs.

A precedence for such a construct is setup_call_cleanup/3 which appears
in the Prolog ISO draft standard and is already included in many systems:

    https://www.complang.tuwien.ac.at/ulrich/iso-prolog/N215

Thank you and all the best!
Markus


In GNU Emacs 25.0.95.4 (x86_64-apple-darwin15.5.0, X toolkit, Xaw scroll bars)
 of 2016-07-05 built on mt-imac
Repository revision: e3b039d1a0e611d6619ed3ce67d125160d644ebc
Windowing system distributor 'The X.Org Foundation', version 11.0.11502000
Configured using:
 'configure --without-ns CFLAGS=-I/opt/local/include
 LDFLAGS=-L/opt/local/lib'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK GSETTINGS NOTIFY ACL GNUTLS
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix






             reply	other threads:[~2016-07-13  6:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13  6:28 Markus Triska [this message]
2018-01-27 21:17 ` bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect 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

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

  git send-email \
    --in-reply-to=m2d1mif3vm.fsf@metalevel.at \
    --to=triska@metalevel.at \
    --cc=23963@debbugs.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.