TSa skribis 2005-09-20 19:06 (+0200):
> Please help me to understand how the context starts to exist.

What do you mean?

Do you want to know what things provide list context?

- hash assignment
- array assignment
- arrayref constructor []
- hashref constructor {}
- slurpy parameters
- list assignment (indeed circular... anyone?)

> strict notion: "when you see a comma you are looking at a list".

But that's not if and only if. What other ways are there to create
lists? Please take into account the entire Perl 6 world, not just the
subsubject at hand (comma operator).

> >my @foo = bar();  # here, what &bar returns is a list, without any
> >                  # comma.
> That @foo is of syntactic type Array is clear. That bar is called
> without parameters is obvious as well. But where do you derive the
> the return type from?

List is not a type. The return *type* is not visible in this snippet.
However, what is returned, is a list.

Lists are ordered collections of scalars. The elements can have types,
a list itself cannot.

bar() evaluates to a list because it is in list context. List context
here is created by the array assignment.

There is no such thing as "returns List" or "--> List", because there is
no type List. List thus also does not have sub or super types.

> That could at most come from type information of bar e.g. :( Void -->
> Blubber) and then the question arises if a Blubber is assignable to an
> Array or not.  Well, or if a Blubber can listify.

Assignable to arrays is everything, because everything can be in list
context and then form a list. A single scalar, when in list context,
forms a list of one element.

Because there is no List type, there is also no such thing as coercion
to or from List. "Listification" is a useless word IMO, but I guess it
could be used to describe things that are in list context: in this case,
everything can "listify".

>   my &foo ::= &prefix:<\>;
> enreferencing should work with
>   ($x,$y) = foo($a,$b);
>  or not?

I think this works, but I was discussing syntax: the function of parens
after \, and how to look at \ compared to other \W and \w+ operators,
syntax wise.


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