ID:2767975
 
I don't know if this is a bug or working as intended so I thought I'd throw it in "On-Topic".

var list/defined_functions = new

#define function(a,b) proc/a() {defined_functions += #a; b}

function(demo,
return(123)\
)

mob/Login()
world << demo()
for(var/i in defined_functions)
world << "Found(<tt>[i]</tt>)"


Created a #define that treats it as if you're defining the name of it as the 1st arg and the code itself as the 2nd argument.

The above code works as expect until you throw in this.

function(demo,
if(1){return(321)}\
return(123)\
)


I receive this error

error: unterminated text doc (expecting "})


function(demo,
if(1){return(321)}\
return(123)\
)


pretty sure you need the parenthesis after function(demo). Currently you're trying to define the contents of the function as arguments with this approach, which; intentional or not, seems like a nonsense thing to try to do with DM.

I get you like using DM in unorthodox ways, but i don't see how that would compile properly to begin with.
In response to Kumorii
Kumorii wrote:
pretty sure you need the parenthesis after function(demo).

No, they are there.
#define function(a,b) proc/a() {defined_functions += #a; b}

Currently you're trying to define the contents of the function as arguments with this approach, which; intentional or not, seems like a nonsense thing to try to do with DM.

The preprocessor has the ability to modify the syntax before it's compiled.

I get you like using DM in unorthodox ways, but i don't see how that would compile properly to begin with.

Programming is a freedom, also the syntax is correct and should compile, I believe the pre-processor is mistaking the { or } after the if statement as the end of the procs encapsulation.