August 03, 2021 Re: Find struct not passed by reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to frame | On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote:
> On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote:
> Why foreach() does not accept a pointer?
pointers don't come with a length?
|
August 03, 2021 Re: Find struct not passed by reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to jfondren | On Tuesday, 3 August 2021 at 19:19:27 UTC, jfondren wrote:
> On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote:
>> On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote:
>> Why foreach() does not accept a pointer?
>
> pointers don't come with a length?
Where is the problem if it points to something with a range interface?
|
August 03, 2021 Re: Find struct not passed by reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to frame | On 8/3/21 12:22 PM, frame wrote:
> On Tuesday, 3 August 2021 at 19:19:27 UTC, jfondren wrote:
>> On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote:
>>> On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote:
>>> Why foreach() does not accept a pointer?
>>
>> pointers don't come with a length?
>
> Where is the problem if it points to something with a range interface?
Must be more complicated than a trivial derefencing:
import std.range;
void main() {
auto r = 5.iota;
auto p = &r;
foreach (e; *p) {
}
}
Having said that, I swear there is a seemingly-over-the-top help of D for foreach loops, which I can't remember now. Similar to what you said, it works with a certain type of construct by thinking outside the box.
Do others know what I am trying to remember?
Ali
|
Copyright © 1999-2021 by the D Language Foundation