ID:1761520
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
X, such that {"[X]"} = {"\n"}.

Basically this would fill the same role as \n (expand to the appropriate newline sequence), except in regular code instead of text.

Requesting this since it seems to be simple or even trivial on the BYOND side, but extremely painful or impossible on the user side. Yes, it's trivial in regex (/s/EOL/\n), but unfortunately the byond preprocessor does not know regex.

Yes, this has a handful of esoteric use cases. They mainly involve preprocessor gymnastics (see http://www.byond.com/forum/?post=1758601#comment13512219), which is useful for long chains of repetitive statements, and cases where syntactic whitespace makes insertion of EOLs in source code desirable (in C it's not included because the argument is that a compliant C compiler should not care about whitespace, but i doubt anyone would say the same about DM).

Just for example, I've got a large variety of compile options in a project that I'm currently working on. Here's what a decent guard clause would look like:

#ifdef SOME_FLAG //Did they define it at all?

#if (((SOME_FLAG)*0) == 0) //False if given a non-number

#if SOME_FLAG //Did they define it as "true" (>1)?
#define SOME_FLAG 1 //Standardize to 1 for safety
#else //So they defined it as something "false" (~0)
#define SOME_FLAG 0 //Standardize to 0 for safety
#endif

#else //This means the value failed to evaluate properly
#error "Only use numbers to set compile options (1 for \
on, 0 for off). This is because the BYOND pre-processor's #if \
statement only allows numbers and pre-processor directives (!)."

#endif

#else //So they didn't define it at all
#define SOME_FLAG 0 //Then define and set to 0 (off)

#endif

Frankly, that's long as heck. Not to mention hideous. And it doesn't even deal with other potential things we could offer, such as setting the value to something above 1 to indicate "turn this on, and remind me it's turned on", or below zero to indicate "turn this off, and remind me it's off". Now consider that this project will probably have a few dozen options at release. That means we'll be copy-pasting this and more for every single one, leading to probably somewhere near 1000 lines of copypasta at release. This isn't acceptable in a high-level language, but if the preprocessor is not feasible to improve, it'd be helpful to give us a tool to hack around it.