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: Garreau\, Alexandre
Subject: Re: Why is there no `until' in elisp?
Date: Wed, 17 Oct 2018 11:14:38 +0200
User-agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu)

On 2018-10-16 at 22:04, Stefan Monnier wrote:
>> I think `until' should refer to the version I gave because this is
>> probably the one which is going to be implemented naively by most people,
>
> I completely reject this kind of argument.
>
> By that argument, we should avoid lexical scoping since dynamic scoping
> is "the one which is going to be implemented naively by most people".

I think you misunderstood me: that’d mean dynamic scoping is something
to implement and keep aside and not remove when implementing lexical
scoping, not that lexical scoping shouldn’t exist.  I said it, I find
your `until' very interesting, so it ought to exist even maybe with a
not-longer name.

It maybe could be an argument against default lexical scoping, while I’m
not against that (afaik it’s only for backward compatibility that emacs
keeps it as default right?), but then I think I should extend my
statement to support what independant experience says, and apply what I
said only to experiences about untested-enough things.

>> also it can be useful to try to retrieve the last body return
>> value, just as it is with `while':
>
> The body of those loops is made of side-effecting operations.
> Usually side-effecting operations don't have useful return values.

They might, but indeed less probably than the cond, so this is a point.
Yet I might notice a cond might usually return a simple t/nil boolean
(for instance when using comparison functions such as (< 1 2), which
keep returning t instead of one of its arguments), which, in case of
`until'/`while', will be known in advance.

>> And then, of course, this introduce useless discrepancy toward
>> symmetry within respect `while'.
>
> No discrepancy: it makes `until` return the value of its last test, just
> like `while` already does (with `while` that value is always nil).

No, `while' currently returns its last body, I just checked:
(let ((x 0)) (while (< x 5) (setq x (+ 1 x))) 8))

Anyway for the non-`while1'/non-`until1' (let’s call them
`whilen'/`untiln' for the sake of speaking) I was talking about a
default `while' (and `until') that would return its cond when there’s no
body, if the working is similar as to `progn' as I stated.



reply via email to

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