On 8 May 2015 at 18:40, Andy Fingerhut <andy.finger...@gmail.com> wrote:

> James, are you saying that with such a core.typed annotation for function
> available in that example, that it would give a warning if available or any
> of the functions it calls accesses any keys other than :stock and :reserved
> ?
>

Yes and no. The function can access other keys, but their type will be
"Any", limiting their use.

For instance, if I changed the function to include an additional key,
without changing the type annotation:

    (defn available [{:keys [stock reserved pending-delivery]}]
      (- stock reserved pending-delivery))

Then core.typed would raise a type error, since [Int Int Any] is not a
valid type signature for clojure.core/-.

However, it might be worth raising the suggestion to Ambrose to add a way
of failing immediately if an unknown key is used, rather than just
assigning the "Any" type.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to