|Suppressing warnings for non-dynamic vars||Mikera||7/22/13 2:33 AM|
While writing the following code for core.matrix:
"Matrix exponent operator. Raises every element in matrix a to the given exponent.
(m/pow a exponent)))
I get the following warning:
Warning: ** not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic ** or change the name. (clojure/core/matrix/operators.clj:19)
The recommendation isn't helpful for me: I don't want ** to be dynamically rebindable, and I like the name as it is thanks. Of course, I don't want the warning either.
What's the solution?
- Some way to selectively suppress the warning?
- Allow a tag like "^:static" to stop the warning?
- Make ** allowable as a non-dynamic name? (solves my case, probably not so helpful for others....)
|Re: Suppressing warnings for non-dynamic vars||Alex Miller||7/22/13 8:06 AM|
I believe Andy has been pushing for ways to suppress warnings locally like this for a while so that proposal is out there (somewhere).
It seems to me that ** is potentially a useful operator name in multiple domains. The current check in Compiler is:
if(!isDynamic && sym.name.startsWith("*") && sym.name.endsWith("*") && sym.name.length() > 1)
It would be a tiny change to make that 1 into a 2 which would allow ** as a valid non-dynamic name.
|Re: Suppressing warnings for non-dynamic vars||Andy Fingerhut||7/22/13 8:41 AM|
The change Alex suggests for this case (allowing ** as a valid non-dynamic name, but nothing else that begins and ends with an asterisk) seems reasonable to me. I don't know any other way to suppress such warnings without changing the compiler.
Alex is probably thinking of this proposal, which was motivated by a desire to suppress individual reflection warnings, and was generalized slightly beyond that to include expression-level modification of *unchecked-math* and could be extended further for other compile-time vars:It doesn't have anything in it for suppressing other types of warnings, though.
|Re: Suppressing warnings for non-dynamic vars||Stefan Kamphausen||7/22/13 12:02 PM|
It occurs to me, that checking for "not made entirely of *'s" might be better, since it would allow symbols like *** and ****. OTOH, maybe it is time to get rid of that warning altogether. Wasn't it supposed to be temporary anyway to smooth the introduction of non-dynamic defaults?
|Re: Suppressing warnings for non-dynamic vars||Mikera||7/23/13 4:32 AM|