jared771 at gmail.com
Fri Oct 18 18:35:45 UTC 2019
On Friday, 18 October 2019 at 17:09:55 UTC, jmh530 wrote:
> On Friday, 18 October 2019 at 16:14:26 UTC, Meta wrote:
>> I wrote that in response to Rikki's assertion:
>> "This unfortunately still ties the implementation itself to
>> the interface. Which goes against DbI."
>> Just some spitballing on how DbI could harmoniously co-exist
>> with Atila's concepts library.
> I'm never quite sure whether I grok DbI or not...but all those
> static if's in phobos's MapResult are introspection to make
> sure that the range type has the appropriate functions and
> include the relevant text in MapResult.
Exactly, making it very hard to use @implements from Atila's
library, because MapResult may or may not implement the necessary
primitives to be, say, a forward range, depending on whether the
source range implements them. Yes, of course you can just use
`isInputRange` instead, but we should aim to provide options, and
I prefer the cleanliness of the former.
> So it seems to me that isInputRange in phobos is
> DbI-compatible, particularly when re-reading what Rikki wrote.
> He seems to be arguing that what you are doing is not DbI
> because you are using interfaces instead.
I may be misunderstanding him, but I believe his main problem
with using interfaces is that the struct conforms to the
interface, but does not inherit its the behaviour (e.g.,
MapResult implements .save only if the underlying range does, and
forwards to its implementation, which is not possible without
extra boilerplate, were we to just allow structs to implement
interfaces as a solution).
Also, interfaces can't have non-immutable fields... and there's
_not_ really any way around that, but at least in the concept of
Phobos ranges, the API consists only of functions, not fields.
My point was that we can do DbI using structs implementing
interfaces, and I provided some strawman implementation to show
how it might be done.
> However, the concepts library has more than just implements.
> Its alternative isInputRange could replace phobos's
> isInputRange or alternately be used used with the models
> template as needed.
Sure, I'm not disputing that.
> In my limited DbI understanding, that would be closer to DbI
> than what you are trying to do.
I disagree, my whole point being that DbI is still possible while
also allowing structs to implement interfaces (which is basically
what @implements is), and maybe preferable in some cases.
More information about the Digitalmars-d