10

I recently edited this question to put the code snippets in blockquotes, since they are from a book the OP is referencing. Shortly after making my edit it was reverted with the description:

Removed extraneous quotation formatting. This is code, not quotation.

In my mind, this is both code and a quotation, but now I'm not sure what the standard is, if any.

4
  • 1
    Well, the purpose of the quote markdown is the improved ability to distinguish what content is the author's and what content isn't. If that can be accomplished by another means, such that it's still clear who authored the content in question, then I don't see a problem. Do you think that readers of that post are likely to mistakenly think that the code was authored by the OP.
    – Servy
    May 18, 2015 at 18:24
  • 1
    What does it matter that those 2 examples came from a book? Are you even certaing those samples are exact copies from a book? There's really no point in adding quote markup around code snippets like that...
    – Cerbrus
    May 18, 2015 at 18:29
  • 2
    @Servy If the reversion description was along the lines of "It's clear from context this code is quoted" I might agree, but that wasn't the rationale given. Even so, I don't see why we would quote an author's words but not their code.
    – dimo414
    May 18, 2015 at 18:30
  • @Cerbrus it sounds like OP is quoting their textbook to me, but I agree it's not entirely clear. Nevertheless, the question is broader - should code snippets copied from external sources, like a book, be quoted?
    – dimo414
    May 18, 2015 at 18:34

1 Answer 1

16

I really don't see the added value of that quote markdown.

It doesn't make the code easier to read, and as far as I can tell they may not even be exact copies of code snippets in the book.

The OP there is just asking what the difference between two code snippets is. Whether or not the code is quoted from a book really is irrelevant for snippets as small as these.

There are probably hundreds of books that mention var a = new Array() vs var a = [], for example. Should questions about declaring arrays now all be formatted with quote markup? I don't think so.

To answer a question you added in the comments:

Should code snippets copied from external sources, like a book, be quoted?

It depends on the snippet.

  • If it's a very specific piece of code that you'd probably only find in a specific book:
    Yes, absolutely, quote and link to the source.

  • If it's just a "concept", or something that could be considered basic knowledge to people familiar with the programming language:
    Don't bother. There's a bazillion sites out there with that code.

6
  • 2
    More generically, I'd argue that there's nothing that's author-specific about the code snippet, so the quote wouldn't serve much purpose.
    – Makoto
    May 18, 2015 at 18:37
  • 1
    @Makoto: Good point, I think my edit should cover that.
    – Cerbrus
    May 18, 2015 at 18:38
  • 1
    @Cerbrus I disagree with using the quote block even for stuff from a book. The important part is the citation, not some random CSS effect. May 19, 2015 at 15:17
  • @DavidGrinberg: "should", not "must", in my opinion. I agree that the most important part is the citation.
    – Cerbrus
    May 19, 2015 at 15:21
  • @Cerbrus You actually say "absolutely, quote and link to the source" May 19, 2015 at 15:22
  • "Absolutely" as an answer to "should...?". I don't see the problem.
    – Cerbrus
    May 19, 2015 at 15:24

You must log in to answer this question.

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