A. Pagaltzis skribis 2006-09-20 22:39 (+0200):
> * Juerd <[EMAIL PROTECTED]> [2006-09-20 22:25]:
> > I think it's time we moved away from the param method, and
> > started using a hash.
> I don???t know about that. The `param` method has the nice property
> that it allows you to pretend everything???s a single value or to
> use multi-valued params, at your own discretion, at any time,
> with no change of syntax.
Thinking that one variable has only one interface is *so* Perl 5 :)
> my $foo = $q->param( 'foo' );
> my @bar = $q->param( 'bar' );
> If you tried to do this with a hash, you???d get
> my $foo = $q->param->{ 'foo' }[0];
> # my ( $foo ) = @{ $q->param->{ 'foo' } };
> my @bar = @{ $q->param->{ 'bar' } };
In Perl 5, yes.
But in Perl 6:
my $foo = $web<foo>;
say $foo;
say $foo[1]; # heck, why not.
my @foo = $web<foo>;
say @foo[1];
All we need is a very simple type that does both Str and Array. We can
handle this, *easily*.
And I wouldn't want the nullbyte mistake again. Let's just stick to the
last given value instead.
Also, I want parameters to be able to do a certain Upload role, which
adds terribly useful methods for file uploads. Let's escape the
primitive world and add some REAL dwimmery, the kind that doesn't
confuse people all the time :)
> Does Perl 6 offer any help in making access to a HoL look like
> the first example?
No, but it does offer help to make it look a whole lot nicer than that.
:)
--
korajn salutojn,
juerd waalboer: perl hacker <[EMAIL PROTECTED]> <http://juerd.nl/sig>
convolution: ict solutions and consultancy <[EMAIL PROTECTED]>
PS
Note that your code, if literally translated to Perl 6, is already
nicer:
> my $foo = $q->param->{ 'foo' }[0];
my $foo = $q.param<foo>[0];
> my @bar = @{ $q->param->{ 'bar' } };
my @bar = $q.param<bar>.'@';
my @bar = @ $q.param<bar>;