Recently I was thinking What will it take to implement function overloading in Arc?
Coincidently came across this: http://www.paulgraham.com/ilc03.html
where pg mentions if wanted it can be implemented as lib(I assume by that he means outside of of language core).
I tried to list down primitives required. ; user defined types
(= udt* (table))
; all overloaded fuctions
(= methods* (table))
; is user defined type?
(def type? (name)
...)
; create a type recognizable type?
; and a function with same name as of typename for creating new instance
(def mktype (name (o initfn))
...)
; overload a function
(def odef (name params . body)
...)
; get function(name) associated with type(udt)
(def get-odef (name udt)
...)
; invoke overloaded function if any else defualt to existing
(def fn-dispatcher (fnname params)
...)
and of course type, annotate and rep(though haven't used it yet)Is it possible to implement fn-dispatcher outside of ac.scm? (I don't know how useful this would be but still.) |