This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: attaching functions to types


On Fri, Mar 20, 2015 at 6:05 PM, Shawn Landden <shawnlandden@gmail.com> wrote:
>    direct-declarator:
>      ( type-qualifier[opt] type-specifier *[opt] identifier[opt] ) .
> function-definition
>
>
> call like so:
>
>
> type.foo(baz);
> typep->foo(baz);


Wait you are re-inventing C with classes and C++.

Thanks,
Andrew

>
> type automatically becomes first parameter, (when used as a function
> pointer) and as a pointer to if that was included in definition. if
> type is a typedef of void and not a pointer then parameters are passed
> the same.
>
>
> This would be implemented with function name mangling:
>
>
> __tf_type_identifier(...)
>
>
> example:
>
>
> struct foo {
> int a
> }
>
> int (struct foo *b).add(int f) {
> return b->a + f;
> }
>
> int main(void) {
>
> struct foo bar;
>
>
> baz.a = 4;
>
> return baz.add(6);
>
> }
>
>
> I have been hacking at the source, but it is far from functional.
> --
> Liberty equality fraternity or death,
>
> Shawn Landden
> ChurchOfGit.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]