On 13.07.21 03:03, someone wrote:
On Monday, 12 July 2021 at 23:28:29 UTC, ag0aep6g wrote:
[...]
I'm not sure where we stand with `in`
You mean *we* = D developers ?
Yes. Let me rephrase and elaborate: I'm not sure what the current status
of `in` is. It used to mean `const scope`. But DIP1000 changes the
effects of `scope` and there was some discussion about its relation to `in`.
Checking the spec, it says that `in` simply means `const` unless you use
`-preview=in`. The preview switch makes it `const scope` again, but
that's not all. There's also something about passing by reference.
https://dlang.org/spec/function.html#in-params
[...]
For a UDT like mine I think it has a lot of sense because when I think
of a string and I want to chop/count/whatever on it my mind works
one-based not zero-based. Say "abc" needs b my mind works a lot easier
mid("abc", 2, 1) than mid("abc", 1, 1) and besides I am *not* returning
a range or a reference slice to a range or whatever I am returning a
whole new string construction. If I would be returning a range I will
follow common sense since I don't know what will be done thereafter of
course.
I think you're setting yourself up for off-by-one bugs by going against
the grain like that. Your functions are one-based. The rest of the D
world, including the standard library, is zero-based. You're bound to
forget to account for the difference.
But it's your code, and you can do whatever you want, of course. Just
looked like it might be a mistake.