[cfe-dev] how to modify clang to allow bolt-on member functions?

walter lynsdale walter_bz at hotmail.com
Sat Apr 20 08:51:39 PDT 2013

#include <iostream>
struct Foo {
    int    x;
    void bar();
void Foo::bar() {//<<<<<< not declared in the class
int main(int argc,const char** argv){
    Foo    f;f.x=10;

Could anyone comment how difficult it would be to modify my own build of clang to allow this to compile. (and provide pointers on which areas of the source to look at)

the motivation is to ease refactoring, and reduce the inconsistency between free functions and member functions. I find myself constantly alternating between them, and this article explains why..

I realise many people familiar with OOP discipline would object to this in principle, but its interesting to see how 'rust' and 'go' work with  their 'open world' philosophy eg traits and implementations.

i wondered if it would break the language design to allow this - I would suggest Foo::bar above hasa the same acess rights as free functions . it seems like a simple idea, and it cant be so obscure as a solution to my 'itch' has appeared in go/rust
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130420/f239657b/attachment.html>

More information about the cfe-dev mailing list