aboutsummaryrefslogtreecommitdiff
path: root/cm/ex02.decl
blob: d695e336ece31c9f5fe1382a1217409cb6a56094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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?