Top 10 perl books

Greg McCarroll greg at mccarroll.org.uk
Thu Apr 24 04:51:55 BST 2008


On Wed, Apr 23, 2008 at 06:39:28PM +0100, Frank v Waveren wrote:
>
> syntactic sugar
> 

Maybe I'm just getting old, but the more I think about syntactic sugar
the more I appreciate it.

Map clearly tells me that you want to move from one list of things to
a transformed list[1], grep tells me you want to reduce a list of things
based on some logic.

The same with

    for (@things) {

vs.

    foreach my $thing (@things) {

The first sets me up to look out for $_. Lastly

    sub foo {
	my $self = shift;
	my ($whatever,...) = @_;

is instantly recognisable as a method.

My feeling is that syntactic sugar helps the equivalent of muscle
memory for the brain, you just dont have to actually consciously think
as much to figure out whats going on.

If I was language designer I think this would be the axe I'd want to
grind - a simple basic language with an evolving set of macros on top
to allow people to figure out how best to explain what low level
patterns are going on.

G.


[1] There is a bit of me that would further like to see this
    constrained to the output having the same number of
    elemements & structure and an additional bit of syntactic sugar
    added for when this is not the case.


More information about the london.pm mailing list