Re:Why Lisp?
by frou_dh on Thursday May 07, 2015 @05:10PM
(#9508325)
In my Lisp-esque language I use a temporary macro to automate the creation of some similar standard library procedures. This happens at runtime in the stdlib source file that is loaded:
The crucial thing about what happens there being that the (def foo? ...) value produced by each macro invocation then gets evaluated in the root/top-level environment and so results in a "global" procedure definition. Using them:
I thought it was a nice contained example of "code writing code" in the data realm.
[ Parent
| on HN ]
Re:Why Lisp?
by GFK_of_xmaspast on Thursday May 07, 2015 @08:49PM
(#9509414)
Python you can do:
def istype(i, t):
return (type(i)==t)
and istype(5, int) doesn't seem that much different than (int? 5)
I bet there's a version in c++ with templates and typeid.
Yeah, I could do similar open testing:
(def is-type (proc (x t) (eq? (type x) t)))
(is-type 5 'int)
But it's nice to have single-parameter ones for FP list stuff. I suppose that 2-parameter version could have their order swapped and do partial application on top of it.Anyway, was just sharing something I had fun making. No language wars intended.