Can this be used in clojurescript?
It looks like yes
But, taking the given clj example, my first question is how can I extend a
protocol to the equivalent of IPersistentMap. Given that maps in
clojurescript are protocols, this seems harder.
D
On Wednesday, 11 July 2012 16:52:47 UTC+10, Leif wrote:
>
> Thanks!
>
> The similarity is no accident: When you consider it, 'isa?' is a
> generalized subtyping relation:
>
> (isa? Double Number) ==> Double <: Number
> (isa? ::goat ::animal) ==> ::goat <: ::animal
> (isa? 1 x) ==> #{1} <: x, which makes sense if you define the value x to
> mean "the set of all things equivalent to x"
>
> Specifically for the keyword case, clojure.core lets you define ad hoc
> hierarchies, which you could view as type lattices. This project lets you
> define ad hoc type lattice relations.
>
> You might be interested in the papers on LIFE. They define "sorts" for
> logic terms (very much like types), and an algorithm for unifying two terms
> (which can be quite a bit more complicated than Prolog terms).
>
> On Wednesday, July 11, 2012 2:22:51 AM UTC-4, Ambrose Bonnaire-Sergeant
> wrote:
>>
>> This is cool :)
>>
>> It reminds me of subtyping between maps in Typed Clojure, where
>>
>> {:a 1, :b 2} <: {:a Number}
>>
>> Thanks,
>> Ambrose
>>
>> On Wed, Jul 11, 2012 at 2:16 PM, Leif <[email protected]> wrote:
>>
>>> Hi, everybody. I reimplemented the function isa? in terms of a protocol
>>> Is-A.
>>>
>>> The reason why you would want to do that is in the README at
>>> https://github.com/leifp/clj-isa-protocol
>>>
>>> tl;dr: One of the reasons why people are excited about predicate
>>> dispatch is the irritation caused by the dispatch function of a multimethod
>>> being closed. You have to decide up front what information the dispatch fn
>>> is going to pull out of your arguments. Changing it afterward is a pain.
>>>
>>> Since the dispatch uses 'isa?' internally, if that function is
>>> extensible, then multimethod dispatch becomes, to a certain extent, open.
>>> See the README.
>>>
>>> Comments, critique, code, and questions welcome.
>>>
>>> Cheers,
>>> Leif
>>>
>>> P.S. As an aside to people that like weird, obscure programming
>>> languages, the rough idea of how is-a? should work for maps was inspired by
>>> (but very much simpler than) the functional logic language LIFE [
>>> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.90.3175 ]
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to [email protected]
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en