Skip to content

Confusion from extend-type/extend-protocol example #55

Description

@cobalamin

https://github.com/swannodette/lt-cljs-tutorial/blob/master/lt-cljs-tutorial.cljs#L1335-L1355

These lines of code and comments seem to suggest that there is some sort of real difference between extend-type and extend-protocol:

;; Or you can extend a protocol on a defrecord.

I wasn't sure, so I read up on them in the docs. The docs for extend-protocol state:

Useful when you want to provide several implementations of the same
protocol all at once. [...] Expands into calls to extend-type

So am I right in assuming that extend-protocol is but a convenience macro that always expands to extend-type calls? If so, the marked lines seem a little bit odd, as we're getting nothing out of using extend-protocol instead of extend-type for a single defrecord, the syntax just seems flipped around and it left me thinking there was a fundamental difference between the two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions