How can I type hint an array?

Viewed 4691

I have the following record:

(defrecord Signal [samples ^double sample-rate ^double scaling-factor])

How can I specify samples to be a double array?

I am using clojure 1.2.0

Edit:

@dreish I get the following output when I call (show Signal) after the changes from levand:

[35] <init> (Object,double,double)
[36] <init> (Object,double,double,Object,Object)
[37] __extmap : Object
[38] __meta : Object
[39] sample_rate : double
[40] samples : Object
[41] scaling_factor : double

I know that hinting of non-primitive type is just used to avoid reflection. From http://clojure.org/datatypes

  • note that currently a type hint of a non-primitive type will not be used to constrain the field type nor the constructor arg, but will be used to optimize its use in the class methods

Thanks everybody!

3 Answers
Related