-
-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isSliceOf to check the origin of a slice #6147
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#6147" |
|
Sorry for not mentioning that one. It's pretty useless (and in the wrong module):
Convince yourself: https://run.dlang.io/is/NoZVWq |
Argh, the spuriously failing std.regex due to its high memory consumption is getting more and more annoying. See also: https://issues.dlang.org/show_bug.cgi?id=18411 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @wilzbach for making ideas become real work.
Any reason to not use the |
Yes -
|
|
So you would treat |
If I had to be pedantic, I would say the nothing is the same as nothing but nothing is not a memory view of nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's too bad to say that null.isSliceOf(null)
is true.
changelog/std-array-sliceOf.dd
Outdated
@@ -0,0 +1,18 @@ | |||
std.array.sliceOf has been added | |||
|
|||
$(REF sliceOf, std,array) provides a `@safe` way to query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a safe way to query what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null thing isn't a blocking issue for me. I approve baring that changelog nitpick.
Tangential to this pull request:
Maybe the documentation needs improvement then, because |
Ping @andralex |
This API could be better. As it is, it returns very little information i.e. "is this range overlapping this other range in any position?" with no further information on position. The same information can be trivially fetched using small.overlap(large) is small or small.overlap(large).length == small.length I like the first one more for generality, and the second more for efficiency. Given the rarity of such a query, I think we don't need a new function for it. BUT! All is not lost. I propose to convert this PR into a documentation PR. The definition and use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify I am asking for changes.
IMO your suggestion fall foul of
If I saw
c.f.
The existence of one-liners on phobos exist precisely to a) stop people reinventing the wheel, and b) use a common name: this fit both of those. Please reconsider. |
(c) must be in frequent use, this doesn't pass that test |
"The overlap of small and large is the same as small itself, i.e. large subsumes small." For somebody in a place in life where they need overlap, this is not quite the leap. |
I agree, but for those not in need of or familiar with |
@thewilsonator wouldn't disagree. I still think this should be relegated to a documentation example. Thanks. |
@andralex I have put |
@thewilsonator you wanted this one. |
@thewilsonator you wanted this one. |
This is has come up before:
tl;dr: of the previous discussion:
overlap
exists, but is confusing to useowns
)sameHead
andsameTail
already exists@trusted
doesn't work for one-linersCC @nordlow @dcarp