ID:2210127
![]() Feb 8 2017, 4:43 am (Edited on Apr 28 2020, 2:11 am)
|
|||||||
| |||||||
.
|
![]() Feb 8 2017, 5:32 am
|
|
The only time this is really necessary is for an asynchronous proc that needs to do a callback for when it's done.
|
The only time this is really necessary is for an asynchronous proc that needs to do a callback for when it's done. Not really, this allows programmers to create things that have similar syntax to byond's internal functions. Like if i wanted to make a new version of foreach that worked with our own special data structures I could do that if i had some way for a proc to take a proc as a arg. You don't have to make a new proc for each if or while or for or spawn but you do for anything you could want to do in softcode? It doesn't have to be that way. |
Most of the benefit from inline functions that I have seen in other languages only appears when you support accessing values from the outer function, which would be far more complex to implement.
|
#define doSomethingElse(a_,b_,c_) \ {\ var/a = a_; var/b = b_; var/c = c_; \ world << "I'm [a] [b] [c]."\ } doSomethingElse("doing","something","else") works already, although semicolons and braces are mandatory as the whole macro body gets packed onto one line. |
Ah. Missed the error. I guess DM can't open new blocks arbitrarily, so instead it would need the typical do-while(0):
#define doSomethingElse(a_,b_,c_) \ do {\ var/a = a_; var/b = b_; var/c = c_; \ world << "I'm [a] [b] [c].";\ } while(0) |
Discussions like this remind me why I love TCL as a language.
In TCL, there is no special snowflake syntax for internal anything, if you want to make a proc that can take args the exact same way an if or while or for does, you can do that, because if/while/etc follows the exact same syntax rules as everything else. |