[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping through an array with FOR EACH
[Thread Prev] | [Thread Next]
- Subject: Re: Looping through an array with FOR EACH
- From: Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
- Date: Thu, 15 Jan 2026 23:26:32 +0100
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Le 15/01/2026 à 22:22, Gianluigi a écrit :
Il 15/01/26 18:55, Brian G ha scritto:I think here we have have Ben step in, because what you are all stating is that 'for each' is a totally unreliable way of for instance listing a newly sorted array of strings... even the hint of a 'maybe not work' in a production environment is not acceptable on any level. I just don't believe for simple arrays that Ben would allow such a bug/ instability to persist as part of such an amazing work!If this is on any level true, perhaps this construct should be removed from the language it is therefore a useless construct.No body should be afraid to use a tool as intended.Dear Brian, Yes, I would really appreciate it if Benoit would say something about this. But it doesn't seem as dramatic as you're making it out to be.There are constructs better suited than others to do a given thing, and constructs better suited to do something else. Now, I speak as someone who's very ignorant on the subject, but I would use FOR EACH to find all occurrences, knowing that the construct will return them all.But if I want to know exactly where the occurrences are, then... Where do you find this reasoning flawed? As far as I know, C doesn't support For Each. With Best Regards Gianluigi
Sorry, I never thought I would have to explain that, because arrays work the same way in every language - except javascript, but who said is was a serious language?
An array is a list of values of the same datatypes that are stored consecutively in memory. Why? Because it's the easiest and fastest way to store and access its contents.
It's a basic data structure that is even often handled by specific CPU instructions, especially on x86.
And so values are indexed by their position, and so it's logical to enumerate them in the index order. Which other order could you use?
And of course, if you modify the array while you enumerate it, you must use your brain to understand which wrong things could happen.
Regards, -- Benoît Minisini.
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | BB <adamnt42@xxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |