3 ms·
Override support, no? function f() { function g() { return 1 } return { g } } function f1(f) { function g() { return f.g() +
by tarkin2 5y ago
Override support, no?
function f() {
function g() {
return 1
}
return { g }
}
function f1(f) {
function g() {
return f.g() + 1
}
return { g }
}
f1(f())
- tsimionescu 5y agoSure, but that's a whole bunch more boilerplate than just .assign(), which was my point (it's easy, but not quite as easy as just calling assign). Especially since f needs to be written a certain way to be overridable, while in the previous example o1 was just an ordinary object. Edit: Not to mention that storing function pointers with each object is a huge waste of memory, versus storing one class pointer in each object, and having that class object store function pointers and parent class pointers. That way, you guarantee that each function pointer is stored exactly once, and each object has a single sizeof(pointer) of overhead (and even this can be improved with more complex implementations).