[Issue 8882] map, filter, iota and zip in pure (and nothrow) functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 16 11:58:18 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=8882
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #4 from monarchdodra at gmail.com 2014-01-16 11:58:06 PST ---
(In reply to comment #2)
> The situation has now improved:
Yeah, thanks Kenji!
> zip can throw because of StoppingPolicy.requireSameLength, and iota(x,y,z)
> throws when z can be 0. iota(x) and iota(x,y) are nothrow.
>
> I think the problem with zip() can be solved introducing an api change, or
> adding a new zip overload that takes StoppingPolicy as first template argument.
Yes, having a run-time condition is awful IMO. It should always be know compile
time. It can also create subtle issues for things such as "hasSlicing", which
only works for certain stopping tipes.
> Fixing iota(x,y,z) is less easy. z is often a value known at compile time, so
> in theory a new version of iota!z(x, y) can be nothrow at run-time.
>
> even iota(x,y) is not nothrow for floating point arguments:
>
>
> import std.range: iota;
> void main() nothrow {
> iota(1.0, 2.0);
> }
>
> test.d(3): Error: 'std.range.iota!(double, double).iota' is not nothrow
> test.d(2): Error: function 'D main' is nothrow yet may throw
Bah, I think illegal input should Error. Problem solved.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list