assume-just
Marc Nieper-Wißkirchen
(16 Jun 2020 20:29 UTC)
|
Re: assume-just
John Cowan
(17 Jun 2020 02:39 UTC)
|
Re: assume-just
Marc Nieper-Wißkirchen
(17 Jun 2020 07:27 UTC)
|
Re: assume-just
Shiro Kawai
(17 Jun 2020 07:33 UTC)
|
Re: assume-just
Marc Nieper-Wißkirchen
(17 Jun 2020 08:00 UTC)
|
Re: assume-just
Shiro Kawai
(17 Jun 2020 08:15 UTC)
|
Re: assume-just Marc Nieper-Wißkirchen (17 Jun 2020 09:50 UTC)
|
Re: assume-just
Arthur A. Gleckler
(17 Jun 2020 17:17 UTC)
|
Re: assume-just
Marc Nieper-Wißkirchen
(17 Jun 2020 17:23 UTC)
|
Re: assume-just
Arthur A. Gleckler
(17 Jun 2020 17:52 UTC)
|
Re: assume-just
Marc Nieper-Wißkirchen
(17 Jun 2020 18:27 UTC)
|
Am Mi., 17. Juni 2020 um 10:15 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>: > > On Tue, Jun 16, 2020 at 10:00 PM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote: >> >> >> `assume` should only do nothing in a mode that is equivalent to "-O3 >> -DNDEBUG=1". > > > srfi-145 encourages so, but I always thought it is a hint to the implementation (such as type declarations in CL). > At least, the code can't count on it raising an error. Maybe we should add a (post-finalization) note to SRFI 145 that (assume x) should be equivalent to what the following would be in the GCC: #ifndef NDEBUG assert (x); #else if (!x) __builtin_unreachable (); #endif > So, the issue comes down to whether you accept (maybe-ref (nothing)) can return #f. Now I think about it, I can always say (maybe-ref obj (cut error "whatever")) if I want to throw an error, so just writing (fn (maybe-ref obj)) for an extra (optional) check may be convenient. Assuming fn is prepared to get #f when obj is Nothing. Note that, strictly speaking, (maybe-ref (nothing) (lambda () (assume #f))) is an error (which is the same as UB in C) to make aggressively optimized compilation possible. So the value can likewise be #t or the expression may not even deliver any values to its continuation.