Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 5187 days ago | link | parent

Do you mean like defgeneric?

Update: I've been mulling adding 'def :type' to wart for some time, so that I can say (def prn(x) :type 'integer ..) rather than (def prn(x) :case (isa x 'integer) ..).:

  (extend-macro def(name params &body body) :case (iso :type (car body))
    `(def ,name ,params :case (isa ,(car params) ,(cadr body))
       ,@(cddr body)))
But I often want to dispatch on different args. I'm not sure the first or last arg are sufficiently common to merit a shortcut.


1 point by Pauan 5187 days ago | link

In my experience, it's usually the first argument, so I think having a :type would be useful, and in the cases where it isn't, you could fall back to :case (isa ...)

But of course, that's up to you.

-----

2 points by akkartik 5176 days ago | link

Yeah after holding off for a week I decided it would be useful.

https://github.com/akkartik/wart/commit/9559f27eec3994d9779b...

Update 2 hours later: Turns out if isa can handle a list of types, so can :type.

https://github.com/akkartik/wart/commit/1a8400dfebb16bd154da...

-----