Search code examples
typesannotationshy

Function Type Annotations


I think Hy is fantastic! Plan on using it, possibly even hacking on it.

I've noticed type annotations are supported, but apparently only for variables, and at most, function arguments. It doesn't seem possible to type annotate function (or method) return values.

Is this potential feature planned for the future? Or is it simply deemed not practical or worth the effort at the moment?

Keep up the great work!


Solution

  • They're implemented, just not documented, so far as I can tell. The syntax is

    (defn foo ^int [x] (+ x 1))
    

    to declare a return value of type int.