Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

two fixups for the arrayop implementation#1903

Merged
WalterBright merged 3 commits intodlang:masterfrom
MartinNowak:fixup_arrayops
Aug 18, 2017
Merged

two fixups for the arrayop implementation#1903
WalterBright merged 3 commits intodlang:masterfrom
MartinNowak:fixup_arrayops

Conversation

@MartinNowak
Copy link
Member

  • add support for mixed vector types
  • fix argument index in initScalarVecs

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @MartinNowak!

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.

}
else static if (isBinaryOp(arg))
{
stack[$ - 2] = "(cast(T)(" ~ stack[$ - 2] ~ " " ~ arg ~ " " ~ stack[$ - 1] ~ "))";
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 existing arrayop behavior only casts the whole RHS before assignment, but not intermediate expressions. This is fixed here.

{
enum not(Args...) = !tmlp!Args;
}
/// find index for which pred!haystack[index] is true or return -1
Copy link
Member

Choose a reason for hiding this comment

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

Please use Ddoc style comments, with Params: and Returns: sections. It's not just for readability, it's so tools can be used on the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.
Note that this already was a ddoc comment and also it's just a private internal helper template with only 5 lines of implementation.

}
}

// std.meta.staticMap
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the documentation for std.meta.staticMap, all it says is:

Evaluates to $(D AliasSeq!(F!(T[0]), F!(T[1]), ..., F!(T[$ - 1]))).

but that is not what this template body does.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's exactly what this template does, in fact I've copied the implementation.
We still need to rename TypeTuple to AliasSeq in this module though.

else static if (isBinaryOp(arg))
{
stack[$ - 2] = "(cast(T)(" ~ stack[$ - 2] ~ " " ~ arg ~ " " ~ stack[$ - 1] ~ "))";
stack[$ - 2] = "(" ~ stack[$ - 2] ~ " " ~ arg ~ " " ~ stack[$ - 1] ~ ")";
Copy link
Member

Choose a reason for hiding this comment

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

Any way this and the following red lines can be turned to green?

Copy link
Member Author

@MartinNowak MartinNowak Aug 18, 2017

Choose a reason for hiding this comment

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

No, it's CTFE only functions as most things in this module.

@MartinNowak
Copy link
Member Author

Done, thanks for the review @WalterBright.

@MartinNowak MartinNowak changed the base branch from stable to master August 18, 2017 11:10
@MartinNowak MartinNowak removed this from the 2.076.0 milestone Aug 18, 2017
@WalterBright WalterBright merged commit acd2c55 into dlang:master Aug 18, 2017
@MartinNowak MartinNowak deleted the fixup_arrayops branch August 19, 2017 10:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants