On Mon, May 25, 2009 at 2:13 PM, Daniel Carrera
<daniel.carr...@theingots.org> wrote:
> In this way, a relatively simple change makes Perl 6 Pod able to do literate
> programing for anyone who is interested.
>
> What do you think?

The main literate programming feature that's missing from POD is the
ability to scramble the order in which the compiler evaluates your
code; this capability can be supplied by means of embedding modules
within the file (to encapsulate those code chunks that you intend to
move around), along with references to them by means of "use"
statements.  For example:

---- start myshell.pl -----
=begin pod
=head1 Intro

This program is an infinite loop. On each iteration we
read user input and do something with it.
=end pod

while 1 {
  use handle_input;
}


module handle_input;
=begin pod
=head1 Handling user input

To handle user input we simply give the input to
Perl's built-in eval() function.
=end pod

print "Prompt> ";
eval(<STDIN>);
---- end myshell.pl -----

There may be some issues about lexical scopes, or not; I'm not sure
off the top of my head.

Thoughts?

-- 
Jonathan "Dataweaver" Lang

Reply via email to