Suppressing warnings for non-dynamic vars

82 views
Skip to first unread message

Mikera

unread,
Jul 22, 2013, 5:33:32 AM7/22/13
to cloju...@googlegroups.com
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....)

Alex Miller

unread,
Jul 22, 2013, 11:06:50 AM7/22/13
to cloju...@googlegroups.com
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.
 
 

Andy Fingerhut

unread,
Jul 22, 2013, 11:41:21 AM7/22/13
to cloju...@googlegroups.com
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

Stefan Kamphausen

unread,
Jul 22, 2013, 3:02:39 PM7/22/13
to cloju...@googlegroups.com
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

Mikera

unread,
Jul 23, 2013, 7:32:37 AM7/23/13
to cloju...@googlegroups.com
Hi Alex, 

This sounds like a sensible minimal change. I just opened a JIRA issue for this:
Reply all
Reply to author
Forward
0 new messages