Click here to Skip to main content
15,886,919 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Here's one I just wrote myself Pin
megaadam12-Oct-17 2:45
professionalmegaadam12-Oct-17 2:45 
RantThe C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
geodoom11-Oct-17 11:35
geodoom11-Oct-17 11:35 
GeneralRe: The C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
den2k8811-Oct-17 22:04
professionalden2k8811-Oct-17 22:04 
GeneralRe: The C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
PeejayAdams11-Oct-17 23:49
PeejayAdams11-Oct-17 23:49 
GeneralRe: The C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
den2k8812-Oct-17 3:30
professionalden2k8812-Oct-17 3:30 
GeneralRe: The C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
megaadam12-Oct-17 3:59
professionalmegaadam12-Oct-17 3:59 
GeneralRe: The C++ primer 5th Edition (by Lippman ), an example of bad way to express something. Pin
madwilliamflint23-Oct-17 4:49
madwilliamflint23-Oct-17 4:49 
GeneralWhen variable names in C# get weird PinPopular
harold aptroot26-Sep-17 1:55
harold aptroot26-Sep-17 1:55 
Take a look at this code
static int test()
{
    int \u0066\u006F\u006F;
    return \u0066\u006F\u006F;
}
Did you know you could do that? I didn't - I knew you could use unicode identifiers (though I never see them in real code), but this is a whole other level of madness.

Obviously that variable is being used but is uninitialized. Try to guess what the compile error will be.
It's not "Use of unassigned local variable '\u0066\u006F\u006F'".

At least it is consistent though, it seems that identifiers written in that style are considered to be identical to the decoded version, so you can mix it with simplify writing it down, and it shows up in intellisense in decoded form and so on.

It gets better. int is a keyword, so it's blue and you can't use it as a name for a local variable except with the @-prefix. So, this works:
int \u0069\u006E\u0074 = 0;
@int++;
That second line can be typed with intellisense auto-completion! That clever bastard knows about the variable called "int" and knows it had better put the @-prefix in front too, just typing "i" calls it up in the pop-up menu. On the other hand, the tool tip for the "int" entry also shows "(local variable) int int", but this is an entry with the value type icon. (this was all in VS2010, it may have changed since then)

In total, I'm not sure whether to feel impressed or disgusted, or a bit of both.
GeneralRe: When variable names in C# get weird Pin
raddevus26-Sep-17 2:23
mvaraddevus26-Sep-17 2:23 
GeneralRe: When variable names in C# get weird Pin
Kornfeld Eliyahu Peter26-Sep-17 2:39
professionalKornfeld Eliyahu Peter26-Sep-17 2:39 
GeneralRe: When variable names in C# get weird Pin
OriginalGriff26-Sep-17 2:51
mveOriginalGriff26-Sep-17 2:51 
GeneralRe: When variable names in C# get weird Pin
harold aptroot26-Sep-17 2:57
harold aptroot26-Sep-17 2:57 
GeneralRe: When variable names in C# get weird Pin
OriginalGriff26-Sep-17 3:08
mveOriginalGriff26-Sep-17 3:08 
GeneralRe: When variable names in C# get weird Pin
RugbyLeague26-Sep-17 4:30
RugbyLeague26-Sep-17 4:30 
GeneralRe: When variable names in C# get weird Pin
Nicholas Marty26-Sep-17 4:47
professionalNicholas Marty26-Sep-17 4:47 
GeneralRe: When variable names in C# get weird Pin
raddevus27-Sep-17 2:02
mvaraddevus27-Sep-17 2:02 
GeneralRe: When variable names in C# get weird Pin
Nathan Minier28-Sep-17 1:59
professionalNathan Minier28-Sep-17 1:59 
GeneralRe: When variable names in C# get weird Pin
Richard Deeming28-Sep-17 3:43
mveRichard Deeming28-Sep-17 3:43 
GeneralRe: When variable names in C# get weird Pin
Nathan Minier28-Sep-17 3:47
professionalNathan Minier28-Sep-17 3:47 
GeneralWe don't work on Sundays Pin
kmoorevs22-Sep-17 9:34
kmoorevs22-Sep-17 9:34 
GeneralRe: We don't work on Sundays Pin
PIEBALDconsult22-Sep-17 14:31
mvePIEBALDconsult22-Sep-17 14:31 
GeneralRe: We don't work on Sundays Pin
kmoorevs23-Sep-17 3:59
kmoorevs23-Sep-17 3:59 
GeneralRe: We don't work on Sundays Pin
Richard Deeming25-Sep-17 2:35
mveRichard Deeming25-Sep-17 2:35 
GeneralRe: We don't work on Sundays Pin
kmoorevs25-Sep-17 4:26
kmoorevs25-Sep-17 4:26 
GeneralThis seriously belongs here... PinPopular
Brisingr Aerowing16-Sep-17 17:22
professionalBrisingr Aerowing16-Sep-17 17:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.