digitalmars.D.learn - 'each' can take static arrays
- =?UTF-8?Q?Ali_=c3=87ehreli?= (11/11) Jun 10 2022 I know static arrays are not ranges but somehow they work with 'each'.
- Adam D Ruppe (5/6) Jun 10 2022 Phobos has dozens of random special cases throughout. I'd prefer
- mw (6/13) Jun 10 2022 Special cases are always bad, inconsistency is a mental burden to
I know static arrays are not ranges but somehow they work with 'each'. With map, I need to slice as 'arr[]': import std; void main() { int[3] arr; arr.each!(e => e); // Compiles // arr.map!(e => e); // Fails to compile arr[].map!(e => e); // Compiles } Why the inconsistency? Ali
Jun 10 2022
On Friday, 10 June 2022 at 16:59:04 UTC, Ali Çehreli wrote:Why the inconsistency?Phobos has dozens of random special cases throughout. I'd prefer if these were all removed, but right now there's just some functions that special case to allow it and others that don't. Apparently each is one that does.
Jun 10 2022
On Friday, 10 June 2022 at 17:27:13 UTC, Adam D Ruppe wrote:On Friday, 10 June 2022 at 16:59:04 UTC, Ali Çehreli wrote:Special cases are always bad, inconsistency is a mental burden to the developers, and can even lead to serious but silent bugs when overlooked. 1) we should fix them as soon as we discover any of them 2) or at least doc such inconsistency with emphasizeWhy the inconsistency?Phobos has dozens of random special cases throughout. I'd prefer if these were all removed, but right now there's just some functions that special case to allow it and others that don't. Apparently each is one that does.
Jun 10 2022