Hacker News new | ask | show | jobs
by puffoflogic 1209 days ago

    define('ISEMAIL_STRING_AT'  , '@');
    define('ISEMAIL_STRING_BACKSLASH' , '\\');
    define('ISEMAIL_STRING_DOT'  , '.');
    define('ISEMAIL_STRING_DQUOTE'  , '"');
    define('ISEMAIL_STRING_OPENPARENTHESIS' , '(');
    define('ISEMAIL_STRING_CLOSEPARENTHESIS', ')');
I find it hard to believe people seriously still do this. This is satire, right?
6 comments

That's because you're not thinking of the future when the @ symbol might change.
Yes but defining it like this does not help much in avoidong future refactoring. The value should be loaded from a property file and/or environment variable at least
That's absurd, you're just asking for failure unless you load it from a dedicated high,-availability microservice built on a dedicated cloud non-relational key-value store.
This doesn't seem too odd to me when considering it may be a convention of writing a lexer. E.g. symbols defined not just one-to-one with ASCII characters, but may also include something like DOUBLE_EQUALS, STRING_LITERAL, NUMBER_LITERAL, etc.
And in fact...

    define('ISEMAIL_STRING_DOUBLECOLON' , '::');
    define('ISEMAIL_STRING_IPV6TAG'  , 'IPv6:');
This is very typical for parsers (characters) and compilers (machine/bytecode).

You could do it with namespaces and `const` though to be less verbose.

I genuinely find this useful, in scenarios where filters and regexes are likely to devolve into punctuation explosions otherwise.
It looks like that's auto generated
Still? That code is 6 years old.