• Ouch! (unregistered)

    Some people will do anything to get an email address :)

  • (cs)

    if (!$comment){ //nobody has posted yet. Just to make sure, we'll check for posts as Comment, instead global $Comment; if (!$Comment){ //where did everybody go? global $posts; if (!$posts){ //I'm getting lonely global $lonely; //I didn't even like them anyways. global $drink; //I'm glad they are gone global $drink_more; // Hey, a lamp shade... global $drink_even_more; // Sosifre, I'm not as think as you drunk I am global $pass_ou

  • Jim Reaper (unregistered)

    I'd love to be the frist dev on his project to use emAilAddreSs

  • Bill's Kid (unregistered)

    [There | there | THERE] [is | Is |IS] [SomeThing | Something | someThing | SOMETHING] [To | to | TO ] [Be | be | BE] [Said | said | SAID] [For | for] [Case | case | CASE] [Insensitivity | insensitivity | INSENSITIVITY]

  • Josh (unregistered)

    But I want to use $emailAddress!

  • Lars (unregistered)

    I PREFER CASE INTENSITY! OH YEAH!

    CAPTCHA: iusto Who knows?

  • Andy (unregistered) in reply to Bill's Kid
    Bill's Kid:
    [There | there | THERE] [is | Is |IS] [SomeThing | Something | someThing | SOMETHING] [To | to | TO ] [Be | be | BE] [Said | said | SAID] [For | for] [Case | case | CASE] [Insensitivity | insensitivity | INSENSITIVITY]

    I think we should introduce word length / abbreviation insensitivity too, just in case people want to use $emailaddr...

  • Geocities? (unregistered)

    Personal Home Page. That is all.

  • Kempeth (unregistered)

    Now if we could only specify the variable name in RegEx that would solve our problems...

  • no name (unregistered) in reply to Kempeth
    Kempeth:
    Now if we could only specify the variable name in RegEx that would solve our problems...

    That would be an awesome language feature - just imagine the potential for abuse...

  • Scott (unregistered)

    where is my $EMAILADDRESS ?

  • Larry (unregistered) in reply to Geocities?
    Geocities?:
    Personal Home Page. That is all.

    Hypertext Preprocessor. That is all.

  • Bert Glanstron (unregistered)

    Dear Murray,

    In case you can’t tell, this is a grown-up place. The fact that you insist on not using coding conventions clearly shows that you’re too young and too stupid to be using Perl.

    Go away and grow up.

    Sincerely, Bert Glanstron

  • not a perl programmer (unregistered) in reply to no name
    Kempeth:
    Now if we could only specify the variable name in RegEx that would solve our problems...
    Isn't that what perl is for?
  • Ouch! (unregistered) in reply to Larry
    Larry:
    Geocities?:
    Personal Home Page. That is all.

    Hypertext Preprocessor. That is all.

    Pathetic Hyperbole Producer (from both, fanbois and detractors)

  • DeGustibusNonDisputandumEst (unregistered) in reply to Bert Glanstron
    Re: The Email Tree 2010-11-03 09:48 • by Bert Glanstron Dear Murray,

    In case you can’t tell, this is a grown-up place. The fact that you insist on not using coding conventions clearly shows that you’re too young and too stupid to be using Perl.

    Go away and grow up.

    Sincerely, Bert Glanstron

    Dear Bert,

    In case you can't tell, that's PHP, not Perl. The fact that you insist on posting your juvenile Bert Glanstron jokes shows that you're too young and too stupid to be posting on TDWTF.

    Go away and grow up.

    Sincerely,

    Everyone

  • Bert Glanstron (unregistered) in reply to DeGustibusNonDisputandumEst
    An Idiot:
    Re: The Email Tree 2010-11-03 09:48 • by Bert Glanstron Dear Murray,

    In case you can’t tell, this is a grown-up place. The fact that you insist on not using coding conventions clearly shows that you’re too young and too stupid to be using Perl.

    Go away and grow up.

    Sincerely, Bert Glanstron

    Dear Bert,

    In case you can't tell, that's PHP, not Perl. The fact that you insist on posting your juvenile Bert Glanstron jokes shows that you're too young and too stupid to be posting on TDWTF.

    Go away and grow up.

    Sincerely,

    An Idiot

    You are an idiot and and should be banned from using your mommy and daddy's modem.

  • (cs)

    What IS the argument for case-sensitive names, anyway?

  • frits (unregistered)

    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

  • Ken B. (unregistered)

    Stupid spam filter won't let me post the one-line Unix shell equivalent.

    Hint: it uses the ${parameter:-word} syntax.

  • Anonymous (unregistered) in reply to frits
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    Puts hand up

  • Flabbergasterisk (unregistered) in reply to Zylon
    Zylon:
    What IS the argument for case-sensitive names, anyway?
    "That's how K&R did it."
  • (cs)

    I think a regexp search on the map that contains the global variables would be a superior solution.

    What?

  • Tim (unregistered) in reply to frits
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    me

  • wtf (unregistered) in reply to frits
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    I've never done anything like this. You can tell, because I haven't flung myself off a tall building, which is what would come next.

  • Steenbergh (unregistered) in reply to frits
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    Sure I have. Then I went and showered for 3 hours to scrub the horrible feel off, and went online to buy $500 worth of Bad Code Offsets...

  • Me (unregistered) in reply to frits
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    Me. I don't even understand what the coder is trying to do. Usually, the WTF has some kind of twisted logic, and I normally mentally translate unfamiliar code into one the coding languages I'm at least semi-familiar with, but this just doesn't make sense.

    So: global $EmailAddress (etc) produces a preassigned global variable? Which is then assigned to another global $email variable, which if false (or null?) results in another preassigned global variable, and so on? What's the point?

  • Ben (unregistered) in reply to Kempeth
    Kempeth:
    Now if we could only specify the variable name in RegEx that would solve our problems...

    You mean something like:

    no strict;
    
    $something_tasty = "some pie";
    @names = grep(/^something_/, keys(%main::));
    print "I'd like to eat ${$names[0]}.\n";
    

    And it's actually a feature, see perldoc exporter:

    use someModule ('/importThese/', '!/butNotThese/', ...);
    
  • (cs) in reply to frits
    frits:
    Seriously, who hasn't had to do something like this?

    ... Anyone who gives a damn about their codebase. If I'm working on a project and I find out that $EmailAddress and $emailAddress are both in use for the same thing, I fix it.

    This code snippet indicates that either the author doesn't give a damn about the codebase, or there's some awful reason that $emailAddress can't be globally replaced with $EmailAddress, even though per the code snippet they are all apparently supposed to contain the email address.

    And I do mean an awful reason. Try to think of a good coding decision that would lead to being unable to replace all the variant capitalizations of $EmailAddress with one consistent version. I'd love to hear it.

  • HerroRygar (unregistered) in reply to Zylon
    Zylon:
    What IS the argument for case-sensitive names, anyway?

    I tend to use them when I feel that I've made a class that is descriptive enough that there is very little value I can add by messing with the variable name too much. For example, in a recent project, I made a class called AssemblyTokenizer. I'm fairly certain that I declared it with...

    AssemblyTokenizer assemblyTokenizer = new AssemblyTokenizer();

    ...because I felt that naming the object "sourceTokenizer" or "tokenizer" or something was just a slightly silly and unnecessary abstraction.

    I dunno. I'm not a case-sensitive diehard, but it is a nice feature.

  • frits (unregistered) in reply to Me
    Me:
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    Me. I don't even understand what the coder is trying to do. Usually, the WTF has some kind of twisted logic, and I normally mentally translate unfamiliar code into one the coding languages I'm at least semi-familiar with, but this just doesn't make sense.

    So: global $EmailAddress (etc) produces a preassigned global variable? Which is then assigned to another global $email variable, which if false (or null?) results in another preassigned global variable, and so on? What's the point?

    If you can't figure this out, than your a moron. The email needs to get set from an ordered priority of places. The only thing is that they happen to be named similarly (except for case). Obviously, you could change the variable names elsewhere to this and it would be readible.

    if (!$email){
        global $primaryEmail; 
        $email=$primaryEmail; 
        if (!$email){ 
            global $secondaryEmail; 
            $email=$secondaryEmail;
            if (!$email){
                global $tertiaryEmail; 
                $email=$tertiaryEmail; 
                if (!$email){ 
                    global $email4; 
                    $email = $email4;
                    if (!$email){ 
                        global $email5; 
                        $email = $email5; 
                        if (!$email){ 
                            global $email6; 
                            $email = $email6; 
                        }
                    }
                }
            }
        }
    }
    
  • (cs)

    I was about to post a comment about how PHP is case-insensitive anyway, but having tried it, it seems that variable names in PHP are case-sensitive. Functions in PHP are case-insensitive; hell, even keywords like "if" are case-insensitive. But variables are case-sensitive.

    What the hell, PHP?

  • Paul (unregistered)

    I use a language which doesn't mind about cases, and an IDE that will normalise the case to the version used in the declaration.

    TRWTF is languages that think i and I are different variables

  • Andrew (unregistered) in reply to Me

    In PHP, global essentially gives you a local access to a global variable. Hence, this code is searching for the right global variable among different naming conventions.

    If you use conventions right, this just doesn't happen, but who actually does that?

  • Deezil (unregistered)

    at least it's not emailAddre$$

    CAPTCHA: quis (This is making me quis-e, seeing all the combinations)

  • Schmalls (unregistered)

    Just so everyone knows, if this is PHP, which it looks like it is, there is no case sensitivity. So $Email and $email are the same variable, etc.

  • X (unregistered) in reply to Zylon

    Here is an argument. It forces the programmer to use the same capitalizations whenever a name is used. Thus information that may be conveyed through case, such as what kind of thing the name represents (whether it be a variable, function, macro, or template parameter), or the starts of words when using camel case, will be visible wherever that name appears.

  • wtf (unregistered) in reply to HerroRygar
    HerroRygar:
    Zylon:
    What IS the argument for case-sensitive names, anyway?

    I tend to use them when I feel that I've made a class that is descriptive enough that there is very little value I can add by messing with the variable name too much. For example, in a recent project, I made a class called AssemblyTokenizer. I'm fairly certain that I declared it with...

    AssemblyTokenizer assemblyTokenizer = new AssemblyTokenizer();

    ...because I felt that naming the object "sourceTokenizer" or "tokenizer" or something was just a slightly silly and unnecessary abstraction.

    I dunno. I'm not a case-sensitive diehard, but it is a nice feature.

    This is perfectly standard, and perfectly readable. One is a class, the other is an object. No Java programmer would have a problem reading this.

  • Christian (unregistered)

    I had to do something like this a couple times, but I encapsulated it into a function to get the ugly into it's own corner and out of the way of the rest of the code. Though since this screams PHP, I would have suggested using an array of names for variables, a foreach over those and the oh so hated variable variable names. It's already a klutz, might at least use a halfway elegant klutz to rescue you yourself from these kind of things.

  • Larry David Jr (unregistered) in reply to Me
    Me:
    frits:
    This is literally the lamest WTF that has ever been posted.

    Seriously, who hasn't had to do something like this?

    Me. I don't even understand what the coder is trying to do. Usually, the WTF has some kind of twisted logic, and I normally mentally translate unfamiliar code into one the coding languages I'm at least semi-familiar with, but this just doesn't make sense.

    So: global $EmailAddress (etc) produces a preassigned global variable? Which is then assigned to another global $email variable, which if false (or null?) results in another preassigned global variable, and so on? What's the point?

    I would wager that the 'email address' is incorrectly defined (i.e. different casing) in various places around the code and this is some sort of attempt to 'mung' them all together in some horrible way.

    That or they were completely mad (or being paid by the line).

  • SR (unregistered) in reply to no name
    no name:
    Kempeth:
    Now if we could only specify the variable name in RegEx that would solve our problems...

    That would be an awesome language feature - just imagine the potential for abuse...

    Imagine the job security.

    Imagine the infamy as junior dev after junior dev saw our magnificent code and posted it the TDWTF

    I'm going to start on such a language tonight. I'll call it SR. No: SR++

  • Steenbergh (unregistered) in reply to Paul
    Paul:
    I use a language which doesn't mind about cases, and an IDE that will normalise the case to the version used in the declaration.

    TRWTF is languages that think i and I are different variables

    Yay! Go VB.Net!

  • wtf (unregistered) in reply to Paul
    Paul:
    I use a language which doesn't mind about cases, and an IDE that will normalise the case to the version used in the declaration.

    TRWTF is languages that think i and I are different variables

    Let me guess - classic BASIC? That's hard core, d00d. You use the line numbers and everything, huh?

  • (cs) in reply to no name
    no name:
    Kempeth:
    Now if we could only specify the variable name in RegEx that would solve our problems...

    That would be an awesome language feature - just imagine the potential for abuse...

    Perl rather than PHP, but...

    $eMailAddress = '[email protected]';
    
    foreach my $key (keys %main::) {
        if($key =~ /emailaddress/i) {
            $email = $$key;
        }
    }
    

    print "$email\n";

  • Philipp (unregistered) in reply to Me
    Me:

    So: global $EmailAddress (etc) produces a preassigned global variable? Which is then assigned to another global $email variable, which if false (or null?) results in another preassigned global variable, and so on? What's the point?

    global (in PHP) imports a potentially previously assigned global variable into the local scope. You can't use a global variable without using the global keyword. In more modern PHP you would use $GLOBAL['<var>'] though, which is always defined.

    The code checks if different global variables were defined before and uses the first one it finds.

  • Lars (unregistered)

    Case sensitive is good. It's kind of annoying when Initialize and initialize is the same name for everyone except people in Turkey.

  • Anon (unregistered) in reply to Zylon
    Zylon:
    What IS the argument for case-sensitive names, anyway?

    Because then I can do things like this:

    private int myInt; public int MyInt { get { return myInt; } set { myInt = value; } }

    Now I can easily tell whether or I'm using the property (MyInt) accessed through the getter and setter (which may do other things - especially notifications for binding in the setter) or the backing field (myInt).

    I know other people prefer to start their backing fields with an underscore, but I've never liked the way that looks.

  • (cs) in reply to SR

    I haven't done much work in PHP, but I'm pretty sure recent versions have a coalesce operator.

  • Christian (unregistered)

    For those not believing that varialbes are casesensitive in PHP: http://php.net/manual/en/language.variables.basics.php First line reads: "Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive."

    And because I just wanted to do it for kicks here my approach to this kind of thing whichi actually runs in a fightiningly large application. It also has comments for why this was done and even a reference to each of the places that would need changing if this was removed, just in case someone gets a bit stir crazy.

    Enjoy

    function getEmail()
    {
    	$names = array(
    		'email',
    		'Email',
    		'Email_Address',
    		'email_address',
    		'EmailAddress',
    		'emailaddress',
    		'EMailAddress',
    	);
    	
    	foreach ($names as $name) {
    		global $$name;
    		$email = $$name;
    		
    		if ($email) {
    			return $email;
    		}
    	}
    	
    	throw new Exception('No email found');
    }
    
  • Philipp (unregistered) in reply to Zylon
    Zylon:
    What IS the argument for case-sensitive names, anyway?

    Compiles faster. No, really.

Leave a comment on “The Email Tree”

Log In or post as a guest

Replying to comment #:

« Return to Article