bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing


From: Markus Triska
Subject: bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect
Date: Wed, 13 Jul 2016 08:28:45 +0200

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 via email to

[Prev in Thread] Current Thread [Next in Thread]