Random Perl 6 syntax rant

Andy Wardley abw at wardley.org
Wed Apr 2 09:02:10 BST 2008

Simon Wistow wrote:
> So clearly annotating a variable with a type is useful - the question is 
> where along the spectrum you want to lie - full on verbosity or minimal 
> decoration.

The most important benefit of Perl's sigils is that they clearly differentiate
variable namespace from keyword namespace.

For example, Perl 5.10 added the 'say' keyword, safe in the knowledge that
it wouldn't trip up any users who happened to be using a variable of the same
name, because  'say' != '$say'.  Of course, this doesn't help anyone who has a
say() subroutine defined, but that's a different kettle of &fish.

But as far as I'm concerned (and I admit my opinion is polarised on this),
that's the only real benefit.  I tend to use references in my code so most
of my data items are scalars, even if they hold references to lists or hashen.

    my $item = 'foo';
    my $list = [ ];
    my $hash = { };

So for me, @ and % are really only used to expand my references to the right

   $a = [ @$list ]
   $b = { %$hash }

I guess I think of them more as operators than sigils.

> I suppose the only way to simplify them would be to make all subroutines 
 > pass-by-reference and simplify down to
>         @array
>         @array[0]

I would make that:

    $array         # the array
    $array[0]      # zeroth item in array
    @array         # all items in array

Note that this implies Highlander Variables - there can be only one '$array',
with '@array' and '%array' meaning what we currently know as '@$array' and

> And is that = a sigil or an operator? 

Or the start of a POD directive?  ;-)


More information about the london.pm mailing list