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

disabled opAssign prevents some valid usage #2

Closed
DmitryOlshansky opened this issue Aug 16, 2011 · 4 comments
Closed

disabled opAssign prevents some valid usage #2

DmitryOlshansky opened this issue Aug 16, 2011 · 4 comments

Comments

@DmitryOlshansky
Copy link

A short example, this fails:

import std.regionallocator;
void main()
{
RegionAllocator alloc; //will initialize later?
auto stack = RegionAllocatorStack(1<<22, GCScan.no);
alloc = stack.newRegionAllocator(); //calls disabled opAssign and fails
}

While it may seem backwards in this case, it's perfectly normal in case I have a struct A, and, for instance, want it to hold aloocator for it's private stack.
e.g. something like this:
struct A
{
RegionAllocator alloc;
this(uint page)
{
auto stack = stack = RegionAllocatorStack(1<<22, GCScan.no);
alloc = stack.newRegionAllocator();
}
//...
}

Workaround for now is to just comment out this opAssign (there is postblit, why disable opAssign?)

@dsimcha
Copy link
Owner

dsimcha commented Aug 16, 2011

I'll think about enabling it. I don't even remember exactly why I disabled it. I think it was just that I didn't see a use case at the time and didn't feel like making some decision on its semantics (i don't remember the details), so I just decided to disable it as the path of least resistance. You're right, though, that allowing manually created stacks makes allowing assignment look a lot more useful.

@dsimcha
Copy link
Owner

dsimcha commented Aug 16, 2011

Now that I look at the code a little more, there are a whole bunch of details about lifetime management/postblits/destructors that no longer make sense given the manual stack creation modification. I'll clean them up and document them better, but that's going to take a day or two.

@dsimcha
Copy link
Owner

dsimcha commented Aug 17, 2011

Fixed. I also cleaned up some resource management, documentation, error handling and performance issues.

@dsimcha dsimcha closed this as completed Aug 17, 2011
@DmitryOlshansky
Copy link
Author

Thanks, I'll try new version then.

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

No branches or pull requests

2 participants