PYRL DOCUMENTATION

(created 00-05-16)
(last update 00-10-23)




What is Pyrl?

Pyrl (and Cython) is a fancy preprocessor which makes Perl look more Pythonish. What it does is, it let indentation control the flow, form the blocks. This means; no curly brackets, no semicolons. It also means you have to be very careful not to miss a space or a tab somewhere.. This sounds harder (does it sound hard at all?) than it is. With a good editor, no problems will arise.
Cython is the 'compiler' that's used for C++ and C files. Pyrl is the 'Pyrl2Perl' 'compiler', it is simply used like the perl program, it supports only the -w flag however.. Simply type pyrl [-w] program at the commandline. You can also 'compile' to perl code and then run the generated perl script.
There is one problem! You can't enter #!/usr/bin/pyrl at the top of your pyrl script, you have to call pyrl program.ply.. I don't know how to make it possible to use this other method. Could anyone enlighten me?

Why?

Because I find it tedious to type semicolons and curlybrackets, and I find the code to be more visually pleasing without those 'unnecessary' characters
Especially in Perl, which I like for quickly throwing things together, I find Pyrl to be a remarkable increase in productivity.



Commandline options

Everything inside [ and ] is optional, all paramters can thus be shortened to one char.

-t[ab]=N    Sets tabstops to be N spaces. Default is 8. Tab definition in the .ply file overrides this.
-w    Passes the -w flag to perl.
-g[enerate]    Generates perl source in a file with the same name as the processed one, but with an .pl ending instead of an .ply one.
-p[retty]    The same thing, although the code is more readable. If you're going to use the perl code, this is the option to use, not -g
-r[un]    Makes the pyrl program call perl on the script and run it. This is done automatically if none of the -g or -p flags are passed. If they're passed and you also want to runt the script at the same time, you have to pass this option.

*All flags/paramters passed after the filename are passed to the generated perlprogram.*


Pyrl synthax

It's simple! It's just like Perl, with the difference that there are no "{" or "}" brackets and no ";" (semicolons).
Blocks are determined by indentation alone, much like in Python (which is why it's called Pyrl.. Python & Perl) I'm not making a claim that it's very Pythonish, the only similarity is that indentation decides blocks.

Note about comments: You have to have at least two spaces or at least one tab before a "#" comment. This is because I'm so lazy at coding that I didn't come up with a better solution for not matching "#"'s in the middle of the code as comments.

Important, you should use an editor you can trust, that doesn't throw in spaces or tabs at will. If a space is missing it could mean a total difference in program execution. Use tabs all the way, thats my recommendation.


Comparsion, plain Perl vs. Pyrl:

In Perl:
if ($bla) {
	print "Yadayada: $bla\n";
	$a = 5;
}
print "more bogus text";
and in Pyrl:
if ($bla)
	print "Yadayada: $bla\n"
	$a = 5
print "more bogus text"

By putting a "{" alone on a row, you indicate that here follows 'pure' Perl code that shouldn't be messed with, the block is finished with a "}" on it's own row:
if ($a)
	print "hello!\n"
{
print "this code won't be messed with," .
	" get the difference?";
if ($perl_rules_the_world_you_have_to_type_all_this) {
	print "ok\n";
}
}
which after 'translation' would become:
if ($a) {
	print "hello!\n";
}

print "this code won't be messed with," .
	" get the difference?";
if ($perl_rules_the_world_you_have_to_type_all_this) {
	print "ok\n";
}
This can be useful for when using the print <<EOF construct, because otherwise pyrl would look at all the indents of the "string lines" after and think of that as code.



Visit the Cython/Pyrl webpage:
www.algonet.se/~jsjogren/oscar/cython/
Mail (bugs to) Oscar Campbell: oscar@linux.nu
Copyright (c) 2000, Oscar Campbell