[racket] Racket/class, inherit-field all
On Apr 3, 2014, at 9:12 AM, Roman Klochkov <kalimehtar at mail.ru> wrote:
> > classes in Racket are themselves *runtime* values
>
> Thank you. Now I understand. I don't remember any language with classes, except Racket with such feature.
It turns out almost all dynamically typed languages treat class in a first-class manner. Here is an example:
class C1(object):
def __init__(self): pass
def m(self): return "c1"
class C2(object):
def __init__(self): pass
def m(self): return "c2"
# f is a mixin, result inherits from C
def f(C):
class Sub(C):
def __init__(self): pass
def n(self): return self.m()
return Sub
c1cls, c2cls = f(C1), f(C2)
[due to Sam TH] -- Matthias
[[ p.s.
> Usually, either a class is a type, so it is defined in compile-time, or there no classes at all and objects just built on a prototype.
Spiritually equating classes with types is a mistake. But yes many explicitly and statically typed languages do so. ]]