int some_func(int a, int b) { class ExampleClass { int whatever(int a, int b) { return a + b; } }; return ExampleClass().whatever(a, b); }
This can be handy for defining, among other things, functors, which would be very nice as a more first-class citizen in DM. Syntax would look something like this:
proc/some_func(a, b)
/ExampleClass // Leading slash to disambiguate from labels
proc/whatever(a, b)
return a + b
var/ExampleClass/c = new /ExampleClass
return c.whatever(a, b)
The fully-qualified typepath of a local type definition would be the fully-qualified path of the procedure plus the local definition of the type - e.g., /ExampleClass above is really of type /proc/some_func/ExampleClass, and is distinguishable from some global type ExampleClass. Local types take precedence over regular types - or perhaps local types must always be fully specified, thus allowing no ambiguity.
Local types are visible outside the procedure they are defined in.
This kind of behaviour can be semi-implemented in DM by writing code like the following:
local_type/some_func/ExampleClass
proc/whatever(a, b)
return a + b
proc/some_func(a, b)
var/local_type/some_func/ExampleClass/c = new /local_type/some_func/ExampleClass
return c.whatever(a, b)
but this is much less elegant, and the local definition version slides into being lambda functionality akin to that in C++0x reasonably easily.
I haven't played with the syntax much, but I'm sure you can do something with it, I'm just not sure how much.