Re: indentation with multiple languages
Richard Hainsworth wrote: One of Masak's irritations with perl6 (http://use.perl.org/~masak/journal/39334) concerns interspacing POD and code. I ran into an analogous problem with a project I am trying to do with perl6. Since perl6 doesnt yet link to the gd library, and I need graphical output, I use perl6 to compile a script for another utility (in my case ploticus). The result is that I have code which looks a bit like perl6 code; perl6 code; $script.say( output code output code ); perl6 code { perl6 code perl6 code $script.say( output code indented output code indented output code ); } perl6 code In other words, I have two languages intermixed, each with its own indentation. I would like to have the indentation of the output (or secondary language) to be dependent on the primary languages indentation. As in the comments to masak's blog, I use indentation to help me with understanding the structure of my program (in perl6). When the output language over-rides the indentation hierarchy in the primary language, I loose the usefulness of indentation. Thus I would like to be able to see: perl6 code; perl6 code; $script.say(' output code output code '); Presumably you want here-docs, which can be indented in Perl 6: perl 6 code perl 6 code $script.say(Q:toEND); output code output code END The leading whitespace will be pruned from the string. Cheers, Moritz
Re: indentation with multiple languages
On Sat, Jul 25, 2009 at 5:03 AM, Moritz Lenzmor...@faui2k3.org wrote: Presumably you want here-docs, which can be indented in Perl 6: perl 6 code perl 6 code $script.say(Q:toEND); output code output code END The leading whitespace will be pruned from the string. All of the leading whitespace, or only up to the amount on the first line? That's always been the problem with here-docs. Rakudo doesn't seem to support Q:to yet, so I can't test, but if I do this: say(Q:toEND); line 1 line 2 line 3 END I would want line1 to be flush left, while line 2 is indented, and line 3 indented more. The solutions to do this in Perl5 are a bit hacky and fragile, something like replacing the simple print END; with (my $str = END) =~ s/^\s{4}//gms; print $str; or similar, which is a lot of work just to get more-legibly-formatted source code. -- Mark J. Reed markjr...@gmail.com
Re: indentation with multiple languages
Mark J. Reed wrote: On Sat, Jul 25, 2009 at 5:03 AM, Moritz Lenzmor...@faui2k3.org wrote: Presumably you want here-docs, which can be indented in Perl 6: perl 6 code perl 6 code $script.say(Q:toEND); output code output code END The leading whitespace will be pruned from the string. All of the leading whitespace, or only up to the amount on the first line? only the amount before the END marker actually. Sorry for not being precise in the first place. See S02:3399 for more details. That's always been the problem with here-docs. Rakudo doesn't seem to support Q:to yet, so I can't test, but if I do this: say(Q:toEND); line 1 line 2 line 3 END I would want line1 to be flush left, while line 2 is indented, and line 3 indented more. Then it'll DWYM ;-) Cheers, Moritz