This is a test

Apr 29, 2008 16:35

=pod

... do not be alarmed.

What happened was that I was talking on Reddit with Masklinn about Literate Programming, and s/he wanted to know if there were any systems other than Literate Haskell which allowed for blog posts which are valid code. "Hrmmm," I thought, "I don't see any obstacle to ( doing that with POD... )

computers, programming, beware the geek, meta, perl

Leave a comment

Comments 22

totherme April 29 2008, 16:07:50 UTC
Is tradition really so important in hacker circles? Should it be?

Reply

pozorvlak April 29 2008, 17:38:42 UTC
I was in a slightly silly mood when I wrote this, as you can probably tell...

Seriously, though, the role tradition plays in computing is an interesting one. For such a young field (and one which is constantly reinventing itself), it certainly has a lot of mythology.

Reply


necaris April 29 2008, 16:52:16 UTC
I imagine you could do something similar using Python doctests...?

Reply

probably, but necaris April 29 2008, 17:06:47 UTC
Python doctests have several issues:

  • it wasn't created for code but for tests, so you have to specify all the ouput lines too (nice for verification, annoying for the writer of a blog post/demo)
  • if I remember well it requires an indentation before the prompt, which will be a pain to render in your post (you'll have to e.g. wrap everything in
    and add an indentation to every code block)
  • Most Python tools don't cope well (there's Emacs doctest-mode but that's pretty much it) with doctest code
  • and since it wasn't created for code, I don't know how it scales with complex classes definitions & stuff

You could probably use it, but it wouldn't exactly be straightforward.

Reply

Re: probably, but necaris April 30 2008, 08:10:21 UTC
Good points -- a pain in the neck, as you say, and probably wouldn't scale at all, but within the realms of possibility. Not something I'll be trying any time soon, in any case ;-)

Reply

Re: probably, but pozorvlak April 30 2008, 09:45:55 UTC
Ah, go on. You know you wanna :-)

Reply


michiexile April 29 2008, 20:16:52 UTC
Doesn't that email filter make it difficult for you if people write you with list-indexing Haskell code (!!) or with arcane combinatorial discussions (involving the factorial of the factorial of something)?

Or, actually, it would seem that the factorial alone would also get killed if I read my regexps right.

Reply

pozorvlak April 29 2008, 20:23:28 UTC
I had a key bound to "read raw text" - if I encountered those situations, I'd use that. But I haven't needed the filter for a few years, anyway :-)

Reply


You simply do not understand it anonym_mouse May 6 2008, 23:13:02 UTC
Holy cow..

[1] You do not understand the idea of literate programming.

It does NOT stand for "voluble commentaries", and POD has nothing to do with it.
Moreover, a program without commentaries can be written in the "literate" style, as defined by Knuth (although that would not be natural or very useful), and vice versa, a program with tons of commentaries and code samples can have nothing to do with literal programming.

The MAIN IDEA is that you can PROGRAM IN HUMAN LANGUAGE, and your ad-hoc invented phrases become precise "variables" or, to be even more precise, MACROS that will expand to valid code.
The "untangle" program will extract this code, in correct machine order, while you are allowed to write in logical order, the order of proper thinking

[2] You miss even the basic usage of "POD" in perl.
It does not escape code unless the first symbol(s) on the line is/are blanks or tabs
So, move your code one space to the right, and POD will preserve it as code.

..without becoming a "literal programming" tool, of course

Reply

Re: You simply do not understand it anonym_mouse May 6 2008, 23:20:50 UTC
.. and to think only that the first reference you gave in your text explains exactly this point, that POD has nothing to do with literal programming ...

oh, well..

Reply

Re: You simply do not understand it pozorvlak May 7 2008, 09:00:34 UTC
I'm glad you spotted that and saved me the effort of pointing it out to you. Though re-reading the text, I see that I could have made this point clearer: I'll fix that now.

Reply

Re: You simply do not understand it pozorvlak May 7 2008, 09:27:27 UTC
[2] Actually, it's you who's misunderstood POD usage. Indentation is how you include code samples in documentation: it's the equivalent of a
block in HTML. What I want to do, however, is include actual running code, for which you use =cut

The difference is easy to see. Save the following as podtest.pl:
=pod

Here is some documentation, including an example C
statement:

print "This line will not be printed.\n";

=cut

print "This line, however, will be printed.\n"; Run perl podtest.pl. Note that the second "print" statement is called, but the first one isn't. Now run pod2html podtest.pl > podtest.html and open podtest.html in your browser. You should see the following:Here is some documentation, including an example print statement:
print "This line will not be printed\n";

BTW, "literate" != "literal".

[Sorry to spam your inbox: stupid markup errors]

Reply


Leave a comment

Up