June 16, 2021

On Wednesday, 16 June 2021 at 10:53:26 UTC, Guillaume Piolat wrote:

>

It's a healthy reminder of just how complicated everything is in C++, often for no good reason.

That statement is true for some things, but not really in this case. He focused on STL style table-pointers. Which is a different concept.

In modern C++ you have ranges and generators. C++ generators are easier to write than D ranges, not much more difficult than generators in Python.

June 16, 2021

On Tuesday, 15 June 2021 at 18:35:04 UTC, Walter Bright wrote:

>

On 6/14/2021 7:29 AM, Steven Schveighoffer wrote:

>

I wonder if there is room for hobbled iterators (cursors) to be in D in some capacity.

Have them be an index, rather than a pointer.

This is a good generic solution for random access ranges. But iterators are about any forward range.

For a forward range, I think something like this does it albeit verbosely:

auto midAndTail = haystack.find(/*...*/);
auto head = haystack.recurrence!((r,n)=>r[n-1].dropOne).until!"a is b"(midAndTail).map!"a.front";

But there is currently no way for a bidirectional range to iterate forward and then turn back. We could agree on a generic range primitive, say turned, that returns a range that iterates back to start that is optional. But then the bidirectional range that supports it will always be bigger because it needs to remember it's start. Hard question.

June 16, 2021

On Wednesday, 16 June 2021 at 11:08:52 UTC, Ola Fosheim Grøstad wrote:

>

On Wednesday, 16 June 2021 at 10:53:26 UTC, Guillaume Piolat wrote:

>

It's a healthy reminder of just how complicated everything is in C++, often for no good reason.

That statement is true for some things, but not really in this case. He focused on STL style table-pointers. Which is a different concept.

Keep in mind that you don't have to implement the full "c++ iterator" in order to support ranged for-loops in modern C++. You only need to implement:

auto b = range.begin() // obtain progress state object
auto e = range.end()   // obtain end-marker

b != e  // comparable to D empty()
++b     // comparable to D popFront()
*b      // comparable to D front()

So it is basically not much more work to support ranged for in C++ than D, but most C++ library authors would implement full table-pointers and then it gets more time consuming.

For an application then there is no need to implement more than you need, obviously.

June 16, 2021

On Wednesday, 16 June 2021 at 10:53:26 UTC, Guillaume Piolat wrote:

>

It's a healthy reminder of just how complicated everything is in C++, often for no good reason.

Size not intended.

June 16, 2021
On 6/15/21 2:35 PM, Walter Bright wrote:
> On 6/14/2021 7:29 AM, Steven Schveighoffer wrote:
>> I wonder if there is room for hobbled iterators (cursors) to be in D in some capacity.
> 
> Have them be an index, rather than a pointer.
> 

How does this work on a linked list?

-Steve
June 19, 2021
I also have the same problems in C++
June 20, 2021
On Saturday, 19 June 2021 at 12:38:42 UTC, Lorenso wrote:
> I also have the same problems in C++

Why?
1 2 3 4 5 6
Next ›   Last »