News for hackers. Stuff that matters.
Re:Interface Dispatch (2018) by userbinator on Thursday April 18, 2019 @08:22AM (#19690444)
With the C++, there is also an optimisation which can be performed: put the method pointers in the object itself, instead of in a vtable. This is beneficial when there aren't so many objects nor methods, since it eliminates one indirection. Instead of obj->table.method() it turns into obj->method(). When I write "OOP" code in C, I usually do this instead of using a separate vtable.

As an aside, I noticed the word "klass", then looked up at the domain name and confirmed my suspicions. ;-)

Re:Interface Dispatch (2018) by microtherion on Thursday April 18, 2019 @09:02AM (#19690657)
"klass" is a common convention in OOP code when referring to classes, because "class" and "Class" are often reserved already.
Re:Interface Dispatch (2018) by mikepurvis on Thursday April 18, 2019 @10:53AM (#19691428)
Python typically goes with `cls`, particularly in conjunction with the `@classmethod` decorator.
Re:Interface Dispatch (2018) by qwsxyh on Thursday April 18, 2019 @12:59PM (#19692648)
Python code uses both.
Re:Interface Dispatch (2018) by mikepurvis on Thursday April 18, 2019 @09:41PM (#19696369)
Um, not really. PEP8 explicitly says to use `cls`:

https://www.python.org/dev/peps/pep-0008/#function-and-metho...

Re:Interface Dispatch (2018) by qwsxyh on Friday April 19, 2019 @08:55AM (#19699153)
Re:Interface Dispatch (2018) by chaosite on Thursday April 18, 2019 @09:53AM (#19690996)
Java seems to prefer `clazz`.
Re:Interface Dispatch (2018) by MaxBarraclough on Thursday April 25, 2019 @06:04PM (#19752924)
"klass" seems to somewhat outnumber "clazz" in OpenJDK, 1541 to 1021. Wonder if there's a reason they haven't settled on one.

https://github.com/openjdk/jdk/search?q=klass

https://github.com/openjdk/jdk/search?q=clazz

Re:Interface Dispatch (2018) by noblethrasher on Thursday April 18, 2019 @12:47PM (#19692528)
C# prefers `@class`
Re:Interface Dispatch (2018) by shereadsthenews on Thursday April 18, 2019 @06:16PM (#19695291)
Doing this prevents a large class of important compiler optimizations. Pitching a DIY vtable as an optimization seems to require a lot of hard evidence.