diff options
| author | rtk0c <[email protected]> | 2025-09-24 01:09:38 +0000 |
|---|---|---|
| committer | rtk0c <[email protected]> | 2025-10-15 20:28:15 +0000 |
| commit | 5124eb80701523ac16928219e9a1031eded128ef (patch) | |
| tree | 165e99dc01bee9d8b00bab09997fe04f772bdefb /cm/ex02.decl | |
| parent | 21da7e16ec4104fa7a4fe489f2c371520e037cc6 (diff) | |
metalanguage design (both lua literals and DSL)
Diffstat (limited to 'cm/ex02.decl')
| -rw-r--r-- | cm/ex02.decl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cm/ex02.decl b/cm/ex02.decl new file mode 100644 index 0000000..394d446 --- /dev/null +++ b/cm/ex02.decl @@ -0,0 +1,20 @@ +// 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? |
