LWN.net Logo

Object-oriented design patterns in the kernel, part 1

Object-oriented design patterns in the kernel, part 1

Posted Jun 2, 2011 12:19 UTC (Thu) by nix (subscriber, #2304)
In reply to: Object-oriented design patterns in the kernel, part 1 by daglwn
Parent article: Object-oriented design patterns in the kernel, part 1

Well, among other things the very article you're responding to provides a number of examples of doing things with vtables which C++ will *not* do automatically for you (e.g. having several different vtables referring to the same object without paying any space cost in that object).

So you'd either have to take an efficiency hit, or do a lot of this stuff manually in C++ as well, which would lead to an ugly mix of inconsistent coding styles.


(Log in to post comments)

Object-oriented design patterns in the kernel, part 1

Posted Jun 3, 2011 14:58 UTC (Fri) by daglwn (subscriber, #65432) [Link]

I believe the variants described could be implemented in C++ via virtual functions (overriding operations for specific types), inheritance-style mixins or the Visitor pattern (both used to add operations to an existing type, the latter being more dynamic than the former).

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds