Ingo Blechschmidt skribis 2005-02-05 17:19 (+0100):
> ...this seems a bit ugly to me.

The "signature" part, or the signature itself? Because you'll encounter
lists like this all over Perl 6 code anyway...

> What do you say about that:
>  use Getopt::Auto;
>  run &main;
>  sub main (
>    Rule $pattern,
>    bool +$help :short("h"),
>    ...
>  ) {
>    ...;
>  }

I dislike "main" routines. Not only because they don't really make sense
to me (subs are for *re*use and structure, and code that by design runs
no more than once needs neither), but also because it means indenting
almost all your code. That may improve readability for that big program
that is structered in lots of subs anyway, but a big left margin does
not add anything to the readability of my simple 200 line script. And I
do not want blocks of more than 24 lines.

Of course, not-indenting is just not an option in curlies :)

I'm very glad "package|class Something;" is there, and could maybe like
your solution if there was also "sub main;", but I think that'd cause
strange readability issues.

> > Probably a macro can handle this, but does (will) Perl parse a
> > signature-like argument list and hand the macro something it can use,
> > or would this require source-filter like trickery?
> With Perl providing &sub.signature, there won't be any need to use
> macros or even source-filters :)

It provides .signature, but that says nothing about how useful this
attribute is. Is it a string? An object? A data structure?

Defining a sub just to retrieve its signature is wrong, IMnsHO. Subs
should be called.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to