March 06, 2018
On Monday, 5 March 2018 at 17:38:52 UTC, H. S. Teoh wrote:
> 	struct Container {
> 		auto opSlice() const {
> 			static struct Result {
> 				private Container impl;
> 				private int n; // internal mutable state
> 				@property bool empty() { ... }
> 				... // rest of range API
> 			}
> 			return Result(this);
> 		}
> 	}

That's definitely a know problem with ranges that hasn't yet been solved.
The known workaround is to implement Range and ConstRange.
This idiom could prolly be encapsulated in a safe and generic template type to avoid boilerplate.
If we had some covariant mechansim to implement sth. similar to

struct Range(T) if (is(T InoutT == inout))
{
    inout(InoutT) opIndex(size_t i) inout;
}

that would be ideal, but that isn't exactly trivial.
I think we had a better issue for this topic, but here is one ticket asking for this feat.
[9983 – inout type can not be used as a parameter for structure template](https://issues.dlang.org/show_bug.cgi?id=9983)
March 07, 2018
On Tuesday, 6 March 2018 at 17:41:42 UTC, H. S. Teoh wrote:
> Yeah, Andrei has admitted before that this is probably what he would do today, if he were given a second chance to design ranges.  But at the time, the landscape of D was rather different, and certain language features didn't exist yet (sorry, can't recall exactly which off the top of my head), so he settled with the compromise that we have today.
>
> As they say, hindsight is always 20/20.  But it wasn't so easy to foresee the consequences at the time when the very concept of ranges was still brand new.

Andrei's 'On Iteration'[0] was published 2009-11-09. Postblits had been in the language for about a year and a half[1], and @disable arrived early 2010[2]. Both features were probably too new to warrant being an integral part of the design of ranges.

--
  Simen

[0]: http://www.informit.com/articles/printerfriendly/1407357
[1]: https://dlang.org/changelog/2.012.html
[2]: https://dlang.org/changelog/2.040.html
March 09, 2018
On Monday, 5 March 2018 Jonathan M Davis wrote at http://jmdavisprog.com/articles/why-const-sucks.html:
>What Java has instead is `final`, which IMHO is borderline useless

In Java `final`  is extremely useful for efficient threadsafe code.
1 2 3
Next ›   Last »