[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