From 81cab430b58b75fe0a6c75722908481dd4d9d55a Mon Sep 17 00:00:00 2001 From: rtk0c Date: Wed, 15 Oct 2025 20:31:31 +0000 Subject: Move imported files into metafang/ dir this metaprogramming attempt was started outside, and then imported here 5124eb80701523ac16928219e9a1031eded128ef..bc8c20d1e93b5c18e8915d356e74024092a74ce8 --- metafang/cm/ex02.decl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 metafang/cm/ex02.decl (limited to 'metafang/cm/ex02.decl') diff --git a/metafang/cm/ex02.decl b/metafang/cm/ex02.decl new file mode 100644 index 0000000..d695e33 --- /dev/null +++ b/metafang/cm/ex02.decl @@ -0,0 +1,22 @@ +// Declarations only version of Cm (like mojo/protobuf? not sure) + +// assume special receiver (as opposed to smalltalk/objC style message passing) +// -- actually, on second thought, this has nothing to do with dispatching (and smalltalk is single dispatch) +// -- (no touching multiple dispatch since that's equivalent to reinventing a new language) +// overloading discouraged, because runtime has to do extra work dispatching +// declare functions outside, with `this` keyword marking receiver +// - in C, func -> prefixed with reciever type, 1st arg is reciever pointer +// - in C++, func -> member function +// - lua (or whatever else), reciever type correspondingly + +Foo { + data +} + +// C: mangling +// C++: overloading +// Lua: generate binding with type detection based dispatcher +fn some_function(this: Foo, arg: i32) +fn some_function(this: Foo) + +// alternative: use S-expression, get rid of parsing step? -- cgit v1.3.1