Ability to define inline functions that work similar to the #define preprocessor but belong to classes.
// They're defined pretty much exactly how procs are.
inline/do_stuff(foo) world << foo
// equivalent to #define do_stuff(foo) world << foo
mob/inline/DoStuff() world << src
The body of the function replaces the invocation at compile-time after the accessor (dot) is type-checked. Any use of src in the inline is replaced by the accessed object.
var mob/m = new
m.DoStuff()
// translates to
var mob/m = new
world << m
// whereas
var obj/o = new
o.DoStuff()
// gives a compile-time error.
Because the body of the inline function replaces the call at compile-time, local variables can be accessed. This means the definition of the body won't be checked for errors unless it's invoked, just like #defines.
mob/inline/check_foo()
// there's no 'foo' variable defined here
// but that's perfectly fine.
// 'src' is replaced with the accessed object.
src << foo
mob/Login()
var foo = 123
check_foo() // replaced with src << foo, so it outputs 123
var mob/m = new
m.check_foo() // replaced with m << foo
This should offer efficiency boosts similar to using #defines due to the lack of procs being called. It would be nice to keep the global scope clear of this stuff.
Another example:
mob/inline/finish_up()
foo += 456
return foo
mob/proc/DoThing()
var foo = 123
finish_up()
del world // doesn't occur; proc returned in the line above
"Real-world example":
atom/movable
inline
Px() ((x-1)*TILE_WIDTH + bound_x + step_x)
Py() ((y-1)*TILE_HEIGHT + bound_y + step_y)
Faster as a #define, but only relevant to movable atoms.