Skip to content

fix Issue 14751 - std.array.array doesn't work with ranges of immutable classes #3524

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

Closed
wants to merge 1 commit into from

Conversation

japplegame
Copy link
Contributor

@Kozzi11
Copy link
Contributor

Kozzi11 commented Aug 4, 2015

LGTM

++i;
result.reserve(length);

foreach (e; r)
Copy link
Member

Choose a reason for hiding this comment

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

Ehm, append still going to check capacity on each element. IIRC it's not that fast since it does a round-trip via druntime's extern(C) API. Much as unfortunate as it is I don't believe the strange use case of immutable classes outweights the performance loss.

I say that immutable class is strange for the reason that:

  • due to no being able to express syntactically tail-const object references is of limited use (very limited at that)
  • OOP is typically about incapsulating mutable state inside of objects.
  • it contains mutable monitor field anyway

@quickfur
Copy link
Member

ping

Any response based on Dmitry's feedback?

@MetaLang
Copy link
Member

Immutable and classes have never worked well together, but we may as well support it if we can.

@japplegame
Copy link
Contributor Author

I need immutability to safely pass class objects (I also need polymorphism) between threads.
Is it a bad design?

@japplegame japplegame closed this Nov 2, 2015
@japplegame japplegame deleted the patch-1 branch January 10, 2016 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants