From: "Garreau\, Alexandre" <galex-713@galex-713.eu>
To: Yuri Khan <yurivkhan@gmail.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: Why is there no `until' in elisp?
Date: Wed, 17 Oct 2018 13:06:51 +0200 [thread overview]
Message-ID: <87k1mgg7ck.fsf@portable.galex-713.eu> (raw)
In-Reply-To: <CAP_d_8V6EgbbTvzeNjKTJEHXW24yy-hUu==qCuTqR27zMpwXjQ@mail.gmail.com> (Yuri Khan's message of "Wed, 17 Oct 2018 16:46:08 +0700")
Le 17/10/2018 à 16h46, Yuri Khan a écrit :
> On Wed, Oct 17, 2018 at 4:23 PM Garreau, Alexandre
> <galex-713@galex-713.eu> wrote:
>>
>> Something such as the C “do” construct might overcomplicate the
>> language, while I think normal `while' and `until' are not only simpler
>> but also superior: with those you have the case of 0 loops, in which
>> basically works as a when.
>
> The post-condition loop enables the “at-least-once” case, which is
> also occasionally useful, e.g.: Attempt an API call until it succeeds.
(…or “until” a non-blocking I/O function blocks)
And no, there’s the no-body form of `while'/`until' which are handy for
that:
(until (call args))
(while (io args))
Or, if you need more instructions because your API is complex:
(until (progn (foo) (call args)))
(while (progn (bar) (io args)))
I’ve saw this form of code idiomatic in basic software such as
coreutils, inetutils, etc.
>> > However, in many languages that have an ‘until’ loop as a language
>> > construct, it is a post-condition loop. The body is executed first,
>> > then the condition is evaluated.
>>
>> Which languages? I looked again in bash to be sure, and bash doesn’t do
>> that.
>
> + Well, you mentioned the C ‘do’/‘while’, for one; it is a
> continuation post-condition loop. C++, Java, PHP, Javascript and many
> other languages inherited that.
> + Pascal has ‘repeat’/‘until’ (a termination post-condition loop), and
> it was my first association for the name ‘until’.
> + In Perl, both ‘while’ (continuation) and ‘until’ (termination) can
> be used as pre-conditions and post-conditions.
The keyword is “can”. There’s no “until cond do thing done” where the
until is placed before and by itself makes it a post-cond. You usually
have a special keyword for trigering post-cond, such as “do” or
“repeat”. Also “loop” in some language I forgot (basic? sql?)
I’m almost sure cl-loop has it. So it’s even compatible with the last.
> − Bash’s ‘until’/‘do’/‘done’ is a termination pre-condition loop, you’re right.
Doesn’t one of the languages you mentioned have a “until” using a
pre-cond rather than a post-cond?
next prev parent reply other threads:[~2018-10-17 11:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 17:42 Why is there no `until' in elisp? Garreau, Alexandre
2018-10-16 19:16 ` Eric Abrahamsen
2018-10-16 19:31 ` Garreau, Alexandre
2018-10-16 20:23 ` Eric Abrahamsen
2018-10-16 23:00 ` Garreau, Alexandre
2018-10-19 15:28 ` Stefan Monnier
2018-10-16 21:28 ` Stefan Monnier
2018-10-17 0:12 ` Garreau, Alexandre
2018-10-17 2:04 ` Stefan Monnier
2018-10-17 9:14 ` Garreau, Alexandre
2018-10-17 15:06 ` Stefan Monnier
2018-10-17 16:51 ` Garreau, Alexandre
2018-10-19 15:34 ` Stefan Monnier
2018-10-19 18:08 ` Garreau, Alexandre
2018-10-17 8:04 ` Yuri Khan
2018-10-17 9:23 ` Garreau, Alexandre
2018-10-17 9:46 ` Yuri Khan
2018-10-17 11:06 ` Garreau, Alexandre [this message]
2018-10-17 17:50 ` Paul Eggert
2018-10-17 21:15 ` Garreau, Alexandre
2018-10-17 21:35 ` Paul Eggert
2018-10-17 21:49 ` Garreau, Alexandre
2018-10-17 22:33 ` Paul Eggert
2018-10-17 22:54 ` Garreau, Alexandre
2018-10-17 12:41 ` Elias Mårtenson
2018-10-17 15:03 ` 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=87k1mgg7ck.fsf@portable.galex-713.eu \
--to=galex-713@galex-713.eu \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=yurivkhan@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).