develooper Front page | perl.perl6.language | Postings from April 2005

[S06] Types of subroutines/blocks/etc.

From:
Ingo Blechschmidt
Date:
April 10, 2005 08:43
Subject:
[S06] Types of subroutines/blocks/etc.
Message ID:
d3bhc8$4mc$1@sea.gmane.org
Hi,

A06 states:
>                               Code
>                    ____________|________________
>                   |                             |
>                Routine                        Block
>   ________________|_______________            __|___
>  |     |       |       |    |     |          |      |
> Sub Method Submethod Multi Rule Macro      Bare Parametric
[...]
> (It's not yet clear whether the C<Bare> vs C<Parametric>
> distinction is useful.  Some apparently C<Bare> blocks are
> actually C<Parametric> if they refer to C<$_> internally, even
> implicitly.  And a C<Bare> block is just a C<Parametric> block
> with a signature of C<()>. More later.)

S06 mentions Bare and Parametric only in the table of standard type
names (with a "at least this week" on top of it).

So, what are the types of the following Code references?
  my $foo = sub ($x) { $x };     # isa Code, Routine, Sub?
  my $foo = sub ()   { 42 };     # isa Code, Routine, Sub?

  my $foo = -> $x { 42 };        # isa Code, Block, Parametric?
  my $foo = { $^x };             # isa Code, Block, Parametric?
  my $foo = { say }; # (uses $_) # isa Code, Block, Parametric?

  my $foo = { 42 };              # isa Code, Block, Bare?
  my $foo = -> { 42 };           # isa Code, Block, Bare?

FWIW, I don't think the distinction Bare<->Parametric is really useful.
And as there's no distinction between C<sub () {...}> and C<sub (...)
{...}> either, I'd vote for dropping the Bare<->Parametric distinction
and updating S06 accordingly.


--Ingo

-- 
Linux, the choice of a GNU | Wissen ist Wissen, wo man es findet.  
generation on a dual AMD   | 
Athlon!                    | 




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About