Skip to content
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

fix Issue 7300 - std.regex.ShiftOr!dchar.search is broken #462

Merged
merged 9 commits into from Mar 30, 2012

Conversation

DmitryOlshansky
Copy link
Member

Aside from fixing this particular bug in one codepath of ShiftOr this includes

  • A start on cleaning up old CTFE and compiler workarounds.
  • Caching regexes was part of original std.regex though it had single recently used slot.

@DmitryOlshansky
Copy link
Member Author

I'm rebasing this. Ehm kills code comments :(

@DmitryOlshansky
Copy link
Member Author

Anything else on this pull? I'd really like to move this forward.

@DmitryOlshansky
Copy link
Member Author

Extended, fixed and rebased.

@dnadlinger
Copy link
Member

Looks fine to me – I wonder, though, if isTwowayCompatible should be publicly documented, so that users can make sense of failing template constraints.

@DmitryOlshansky
Copy link
Member Author

If documented then we are looking for a better name, something like isTwowayOrder or isTwowayComparator, or whatever.

@DmitryOlshansky
Copy link
Member Author

Ok, I've settled on just documenting isTwoWayCompatible. Any good ideas for renaming it are still welcome.

andralex added a commit that referenced this pull request Mar 30, 2012
fix Issue 7300 - std.regex.ShiftOr!dchar.search is broken
@andralex andralex merged commit 84a847c into dlang:master Mar 30, 2012
enum isTwoWayCompatible = is(typeof( (){
T1 e;
T2 v;
return fn(v,e) && fn(e,v);
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation is inconsistent with the example, and both are inconsistent with the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the example is what documentation states.
Yet, the actual test code is even more restricted.
I'll make a pull to get this in line.

Copy link
Contributor

Choose a reason for hiding this comment

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

The example also requires that T1 and T2 are default-constructible. You could initialize them with void to fix this.

Copy link
Member Author

Choose a reason for hiding this comment

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

The trick is ... it doesn't compile with:
T1 e=void;
T2 v=void;
fn(v,e);
fn(e,v);

I believe it has something to do with string predicates.
Like compiler checking "value used before initialized", it works ok for => predicates.

Problem happens with code like this:
import std.range;

void main(){
int[] abc = [1, 2, 3];
auto srange = assumeSorted!"<="(abc);
srange.lowerBound(2);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What about

T1 foo();
T2 bar();

fn(foo(), bar());
fn(bar(),foo());

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice one.
#521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants