Ranges

Ali Çehreli acehreli at yahoo.com
Sun Aug 7 05:12:38 UTC 2022


On 8/6/22 14:10, pascal111 wrote:

 > the problem is that ranges in D lack the usage of pointers as
 > an essential tool to make all of ranges functions they need. If ranges
 > exist in C, they would use pointers, and this is

There are a few cases where pointers provide functionality that ranges 
cannot:

1) Some algorithms don't make much sense with ranges. For example, most 
of the time find() can return just the element that we seek. In D, 
find() returns a range so that we can chain it with other algorithms.

2) Some algorithms like partition() better use three pointers.

Other than that, ranges are superior to pointers in every aspect. (I 
resent the fact that some C++ "experts" used those two points to decide 
ranges are inferior and helped deprive the C++ community of ranges for a 
very long time. The same "experts" did the same with 'static if'.)

 > a powerful point in the account of C.

I missed how you made that connection.

Ali



More information about the Digitalmars-d-learn mailing list