Jason Grossman
unread,Oct 13, 2009, 9:13:51 PM10/13/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Programming Nu
I'm used to prototype-based programming, from Io and Ioke.
It's nice and easy to do prototype-based programming in Nu: just make
all your new objects classes, and all your new methods class methods.
Existing instance methods (from the libraries) can be converted into
class methods, either automatically or as required. This seems to
give the same kind of differential inheritance as I'm used to. It can
be made prettier by defining a new word, say "proto", to mean the same
as "class", thus:
(macro-1 proto (*body) `(class ,@*body))
(By the way, I'm surprised to see that "macro" is still "macro-0".
Shouldn't it be "macro-1"?)
A toy example:
(proto animal is NSObject
(+ call is "I don't know what to say.")
(+ size is "unknown"))
(proto dog is animal
(+ call is "woof!"))
(dog call)
;; returns "woof!"
(dog size)
;; returns "unknown"
Now for my question: is there a major efficiency problem with doing
this?