October 14, 2013 [Issue 11252] New: "in" operator for std.range.iota | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11252 Summary: "in" operator for std.range.iota Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-10-14 02:47:58 PDT --- In Python sometimes I have code like this that I'd like to translate to D, it contains a pattern that was forbidden in D: if (... and 1 < foo(2) < 10 and ...): ... If the call to foo() is not pure or you don't want the risk of calling it two times, in D you have to split that if() in two and use an extra variable: if (...) { const temp = foo(2); if (temp > 1 && temp < 10 && ...) { ... } } To avoid some of such problems I suggest to add the support for the "in" operator to iota(): if (... && foo(2) in iota(1, 11) && ...) { ... } In another ehnancement request I've suggested to support the "[]" syntax in iota(): if (... && foo(2) in iota!"[]"(1, 10) && ...) { ... } This usage of iota is useful only for numerical intervals, so it doesn't cover all usages of the Python x<y<z syntax, but I think it covers most of my translations from Python. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation