develooper Front page | perl.perl5.porters | Postings from April 2012

Re: [perl #108286] Wishlist: Overridable keywords

Thread Previous | Thread Next
From:
jvromans
Date:
April 24, 2012 11:40
Subject:
Re: [perl #108286] Wishlist: Overridable keywords
Message ID:
20374.62330.316395.428105@phoenix.squirrel.nl
[Quoting Jesse Luehrs, on April 24 2012, 13:18, in "Re: [perl #108286] W"]
> I have on occasion wished for a more functional programming-style if
> statement:
> 
>   my $foo = if ($foo->bar) { $bar } else { $baz };
> 
> It is a lot more readable than ?: when the expressions get more
> complicated.

I definitely agree.

> Looking at it from the other side, I really don't understand what
> making an arbitrary distinction between keywords that are allowed to
> be overridden and keywords that aren't allowed to be overridden
> actually gains us. That is just extra arbitrary restrictions that
> have to be remembered, which just adds complication. Why do you
> think this makes anything simpler?

Because, as was remarked earlier in this thread, overriding if() is
asking for trouble.

But again -- overriding if, else and elsif as a whole (cf. tie) would
be feasible. Bot not as loose keywords.

I cannot imagine a sensible purpose to override else. Can you?

-- Johan

Thread Previous | Thread Next


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