emacs-devel
[Top][All Lists]
Advanced

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

Re: Why is there no `until' in elisp?


From: Yuri Khan
Subject: Re: Why is there no `until' in elisp?
Date: Wed, 17 Oct 2018 16:46:08 +0700

On Wed, Oct 17, 2018 at 4:23 PM Garreau, Alexandre
<address@hidden> 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.

> > 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’.
− Bash’s ‘until’/‘do’/‘done’ is a termination pre-condition loop, you’re right.
+ In Perl, both ‘while’ (continuation) and ‘until’ (termination) can
be used as pre-conditions and post-conditions.



reply via email to

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