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

std.array: Allow joining constant arrays #1865

Merged
1 commit merged into from Feb 16, 2014

Conversation

CyberShadow
Copy link
Member

Fixes this:

const string[] arr = ["apple", "banana"];
arr.join();

@monarchdodra
Copy link
Collaborator

I wish we had an Ifti! template for this. This would help solve the issue of const ranges all around.

@Poita
Copy link
Contributor

Poita commented Jan 25, 2014

I'm always a bit concerned with liberal use of Unqual like this. Surely this would break with a class-type const range, e.g. const InputRange!E? I'm not sure you can just cast away the const like that, but maybe I'm wrong.

@monarchdodra
Copy link
Collaborator

Surely this would break with a class-type const range

As far as I can tell, the change is fine because nothing actually ever gets casted away. This merely relaxes the constraints, but the function still operates on the actual types. The types stored are still the raw RoR and ElementType!RoR

This means that while our constraints will now accept const ranges, nothing guarantees the implementation will actually compile correctly.

So I don't think this could actually lead to undefined behavior (which is good), but can lead to compile errors (which is bad), but accepts code that was (arguably) valid, but previously rejected (which is bad).

@CyberShadow
Copy link
Member Author

I guess instead of Unqual we need CanRemoveHeadConstByAssignment or something like that?

@Poita
Copy link
Contributor

Poita commented Jan 25, 2014

I currently have a pull request for CompatibleUnqual, which does exactly
that.
On 25 Jan 2014 21:10, "Vladimir Panteleev" notifications@github.com wrote:

I guess instead of Unqual we need CanRemoveHeadConstByAssignment or
something like that?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1865#issuecomment-33300745
.

@CyberShadow
Copy link
Member Author

I currently have a pull request for CompatibleUnqual, which does exactly that.

What's the pull request number? What's its status, is it merged? Does it make this one obsolete?

@Poita
Copy link
Contributor

Poita commented Feb 12, 2014

It's here: #1881

It's not merged, and unknown whether or not it will be.

It doesn't make your change obsolete. It would just change your Unquals to CompatibleUnquals, so that it's more correct for ranges with indirections.

I think we should still merge your change in the meantime.

LGTM

@ghost
Copy link

ghost commented Feb 15, 2014

Auto-merge toggled on

ghost pushed a commit that referenced this pull request Feb 16, 2014
std.array: Allow joining constant arrays
@ghost ghost merged commit 7330607 into dlang:master Feb 16, 2014
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants