D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4783 - atomicOp!"^^" doesn't work b/c it doesn't have access to std.math
Summary: atomicOp!"^^" doesn't work b/c it doesn't have access to std.math
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-01 07:34 UTC by David Simcha
Modified: 2016-10-08 21:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-09-01 07:34:24 UTC
import core.atomic;

void main() {
    int num1 = 1;
    int num2 = 1;
    int res = atomicOp!"^^"(num1, num2);
}


Errors:

d:\dmd2\windows\bin\..\..\src\druntime\import\core\atomic.di(96): Error: must import std.math to use ^^ operator
d:\dmd2\windows\bin\..\..\src\druntime\import\core\atomic.di(6): Error: template instance core.atomic.atomicOp!("^^",int,int) error instantiating
Comment 1 Don 2010-09-01 07:55:12 UTC
That's correct. You need to import std.math if you want to use ^^.
Comment 2 Don 2010-09-01 07:59:05 UTC
(In reply to comment #1)
> That's correct. You need to import std.math if you want to use ^^.
Oh sorry. Misunderstood. Yes, ^^ should not be used anywhere in core.*
Comment 3 David Simcha 2010-09-01 08:10:51 UTC
Then if ^^ isn't going to be usable w/o importing std.math anytime soon, I guess we need to get rid of it from core.atomic.
Comment 4 David Simcha 2010-09-01 08:38:37 UTC
...or, since the whole thing is based on doing the operation and CASing back the result, we could make a version of atomicOp that takes an arbitrary lambda expression.
Comment 5 Don 2010-09-01 11:03:58 UTC
(In reply to comment #3)
> Then if ^^ isn't going to be usable w/o importing std.math anytime soon, I
> guess we need to get rid of it from core.atomic.

Yes. Something so high level has no business being in core. pow() for floating point exponents is a *huge* function.