3 ms·
Well, that's what C++ templates were made for. White your code to work on Musicians, pass Taylor Swift in. If she's not a musician, your code won't compile.
by romwell 2y ago
Well, that's what C++ templates were made for.
White your code to work on Musicians, pass Taylor Swift in.
If she's not a musician, your code won't compile.
- PaulHoule 2y agoWhat I am talking about is more dynamic, although meta-objects could be made more static too. Particularly, I am not a Musician now but if I learned to play an instrument or performed at a concert I could become a Musician. This could be implemented as paulHoule.isA(Musician.class) # false paulHoule.as(Musician.class).playsInstruments() # an empty Set<Instrument> paulHoule.as(Musician.class).playsInstruments().add(trumpet) paulHoule.isA(Musician.class) # now true I really did build a very meta object facility that represented objects from this system https://en.wikipedia.org/wiki/Meta-Object_Facility https://en.wikipedia.org/wiki/Meta-Object_Facility in an RDF graph and provided an API in Python that made those objects look mostly Pythonic. Inheritance in MOF is like Java so I didn't need to use any tricks to make dynamic classes (possible in RDF) available.
- mhuffman 2y agoThis is interesting. It seems like a logic language (like Prolog) would work more naturally.