A
Anno Siegel
Top level blocks, that is, blocks at file level, serve many useful
purposes. An example is, in a module file, a related module or class
you want to incorporate in the main file. It rightly belongs into a
BEGIN block. Another example is a test file (t/*.t), where tests often
form groups. It is useful to put each group in its lexical space, which
means that most of the file is inside one top level block or another.
In such cases, indentation comes as a nuisance. I have taken to using
double braces, '{{' and '}}' to delimit top level blocks that aren't
indented. I'm using them because the don't appear "naturally" in Perl
(or do they?) and they don't hurt (or do they?). I also hope to say
something like "Yes, this *is* a block. I'm still not indenting", but
that is perhaps hoping a bit much.
The main question is, of course, how much does the lack of indentation
hurt? I don't notice more block structure mixups in sources where I'm
using that style, but then I'm biased. I did notice more mixups when
trying to *nest* double braces, so I'm not totally insensitive. Never
nest them, by definition double braces only apply to top level blocks.
In any case, before I release any code in this style to CPAN, I'd like
to test the waters and ask if that would, umm..., get me talked about.
If anyone cares to take a look at some code, I have put up two examples,
a module and a test file, under
http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/Module.pm
http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/test-file
Please, these are only to look at. They are taken as-is out of some
ongoing work. I'm reasonably sure they compile, but that's it. (And
don't anyone *dare* tell me it's undocumented, man do I know it
Anno
purposes. An example is, in a module file, a related module or class
you want to incorporate in the main file. It rightly belongs into a
BEGIN block. Another example is a test file (t/*.t), where tests often
form groups. It is useful to put each group in its lexical space, which
means that most of the file is inside one top level block or another.
In such cases, indentation comes as a nuisance. I have taken to using
double braces, '{{' and '}}' to delimit top level blocks that aren't
indented. I'm using them because the don't appear "naturally" in Perl
(or do they?) and they don't hurt (or do they?). I also hope to say
something like "Yes, this *is* a block. I'm still not indenting", but
that is perhaps hoping a bit much.
The main question is, of course, how much does the lack of indentation
hurt? I don't notice more block structure mixups in sources where I'm
using that style, but then I'm biased. I did notice more mixups when
trying to *nest* double braces, so I'm not totally insensitive. Never
nest them, by definition double braces only apply to top level blocks.
In any case, before I release any code in this style to CPAN, I'd like
to test the waters and ask if that would, umm..., get me talked about.
If anyone cares to take a look at some code, I have put up two examples,
a module and a test file, under
http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/Module.pm
http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/test-file
Please, these are only to look at. They are taken as-is out of some
ongoing work. I'm reasonably sure they compile, but that's it. (And
don't anyone *dare* tell me it's undocumented, man do I know it
Anno