News for hackers. Stuff that matters.
Re:Better C – A subset of D Programming Language by FeepingCreature on Tuesday April 28, 2020 @08:12AM (#23006223)
D has functors, but it doesn't have 'Functor'.

Or rather, D doesn't have concepts (of which 'Functor' is a special case); that is, the notion of a type that is characterized by having the ability to execute operations is not expressible in its typesystem.

Or rather, it is, but only with classes. You want something like "a return type; fulfilling the condition of being able to be used in this way." This is not something you can specify as a function attribute in D. Instead, ranges use a form of duck typing. The next step in the call chain can tell whether the previous step gave it something it can use using template inconditions, ie. `isInputRange!T`. But the previous step can't assert that it is returning a type that fulfills a constraint. In other words, there's type inconditions but not type outconditions.

Re:Better C – A subset of D Programming Language by tomp on Tuesday April 28, 2020 @10:11AM (#23007128)
What you're describing has names - structural types, refined types (a.k.a. contracts a.k.a. pre- and post-conditions)...

It's simply a failure of D the language/compiler (and a huge anti-pattern) to not expose internal types in a way that can be displayed to the programmer.

Re:Better C – A subset of D Programming Language by FeepingCreature on Tuesday April 28, 2020 @10:19AM (#23007205)
No such internal type exists. The range interface is purely a library feature. The problem is that D has no way to include a type constraint as a part of the function type, at present. Something like out template contracts would do it probably.
Re:Better C – A subset of D Programming Language by guai- on Wednesday April 29, 2020 @10:55PM (#23026999)
java can't express its types in its own syntax either. nor scala, nor sharp.

ceylon could, but they are barely readable anyway.