Suppressing warnings for non-dynamic vars

Showing 1-5 of 5 messages
Suppressing warnings for non-dynamic vars Mikera 7/22/13 2:33 AM
While writing the following code for core.matrix:

(defn **
  "Matrix exponent operator. Raises every element in matrix a to the given exponent.
   Uses clojure.core.matrix/pow."
  ([a 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.


--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Suppressing warnings for non-dynamic vars Andy Fingerhut 7/22/13 8:41 AM
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:

    http://dev.clojure.org/display/design/Overriding+compile-time+var+values+at+expression-level+granularity

It doesn't have anything in it for suppressing other types of warnings, though.

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.

Andy

Re: Suppressing warnings for non-dynamic vars Stefan Kamphausen 7/22/13 12:02 PM
Hi,


On Monday, July 22, 2013 5:06:50 PM UTC+2, Alex Miller wrote:

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.


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?


Kind regards,
Stefan
Re: Suppressing warnings for non-dynamic vars Mikera 7/23/13 4:32 AM
Hi Alex, 

This sounds like a sensible minimal change. I just opened a JIRA issue for this: