Skip to content

Conversation

@wilzbach
Copy link
Contributor

Split-up from #5962

Motivation: Named tuples are a lot better to read.

There has been a precedent for this, see #5436

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@wilzbach
Copy link
Contributor Author

Note that findSplit return auto, so it's less problematic to change the return type here.


@safe unittest
{
import std.typecons : tuple;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary, it's imported at the top

$(REF findSplit, std,algorithm,searching),
$(REF findSplitBefore, std,algorithm,searching), and
$(REF findSplitAfter, std,algorithm,searching)
will return a named tuple tuple instead of an anonymous tuple:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "tuple tuple" > "tuple"

@wilzbach wilzbach force-pushed the searching-findSplit branch from 9a45368 to 943f229 Compare January 7, 2018 01:53
- `std.algorithm.searching.findSplit`
- `std.algorithm.searching.findSplitBefore`
- `std.algorithm.searching.findSplitAfter`

will return a named tuple tuple instead of an anonymous tuple:
std/typecons.d(648): Error: reinterpreting cast from inout(string)* to inout(Tuple!(string, string, string))* is not supported in CTFE
std/traits.d(566):        called from here: findSplit(s, "(").asTuple._Tuple_super()
std/traits.d(568):        called from here: adjustIdent("std")
std/traits.d(556): Error: template instance std.traits.fqnSym!(std) error instantiating
std/traits.d(556):        instantiated from here: fqnSym!(traits)
std/traits.d(478):        instantiated from here: fqnSym!(fullyQualifiedName)
std/traits.d(484):        instantiated from here: fullyQualifiedName!(fullyQualifiedName)
std/traits.d(484):        while evaluating: static assert(fullyQualifiedName!(fullyQualifiedName) == "std.traits.fullyQualifiedName")
@wilzbach wilzbach force-pushed the searching-findSplit branch from 943f229 to 8becc70 Compare January 17, 2018 11:50
@JackStouffer
Copy link
Contributor

Let's move forward with this.

@dlang-bot dlang-bot merged commit c07b09e into dlang:master Jan 24, 2018
@wilzbach wilzbach deleted the searching-findSplit branch January 26, 2018 16:23
@jacob-carlborg
Copy link
Contributor

This broke DStep [1]. It's the same error as the second commit 8becc70 in this PR fixes. But according to the documentation of Tuple [2] it should be possible to use both indexing and names to access the elements of a tuple.

[1] https://travis-ci.org/jacob-carlborg/dstep/jobs/333759750
[2] https://dlang.org/phobos/std_typecons.html#Tuple

@jacob-carlborg
Copy link
Contributor

I can we please revert this. It broke Phobos and DStep, then it's likely that it will break other projects as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants