What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 129 Stack Exchange communities.

I'd like to be able to have an option when writing code snippets to identify it graphically as a counter-example or a demonstration of a mistake, not the actual code solution to the question.

I'm not a graphic designer so I don't know how it could visually distinguish itself; maybe red text? Red background-color?

Either way, I'd like some visual indicator so that someone breezing over the question will get an immediate impression that the code snippet is deliberately wrong for the sake of explanation and example.

share|improve this question

2 Answers 2

I just use comments to draw attention to the intentional mistake:

// this is wrong and you are wrong for using it
****pointer = *(*(*(++x))).x;

// this is correct
pointer = magic;
share|improve this answer
    
I do too, but sometimes I'm using a code snippet to represent output or expected output versus actual output and it doesn't feel appropriate to add comments. Nonetheless, this is a valid solution - +1. –  Richard JP Le Guen Dec 7 '12 at 17:41
    
you can also add headers to the top of the code block to tell readers what it's supposed to be –  Sam I am Dec 7 '12 at 18:03

You can use strikeout — rather carefully:

// This is wrong!
****pointer = *(*(*(++x))).x;

// This is correct
pointer = magic;

The magic is:

<s>

    // This is wrong!
    ****pointer = *(*(*(++x))).x;

</s>

    // This is correct
    pointer = magic;
share|improve this answer
    
(ab)useful feature! –  user7116 Dec 9 '12 at 3:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .