On 2010-07-31, at 2:00 pm, TSa (Thomas Sandlaß) wrote:
> On Saturday, 31. July 2010 18:56:47 David Green wrote:
>> given $who-knows-what {
>> when True { say "It's a true thing!" }
# ^--oops, this still shouldn't come first!
>> when 42 { say "It's numbery!" }
>> whenever timeout() { say "Who cares what you say, time's up!" }
>> whenever $override { say "Whatever, switching to automatic override" }
>> }
>
> Am I getting your intention to be that when honors the given and whenever
> just checks truth? Couldn't we use if for this? That would avoid the new
> keyword.
Right; except that "whenever" still breaks out, unlike "if". I like having a
new keyword because it makes it perfectly clear that "whenever $foo" does not
mean the same thing as "when $foo" (though it suggests something related by
having "when" in the name).
However, as suggested in my previous message, we could also distinguish them
with something like "when" vs. "when:". The colon there isn't quite a new
keyword, but it still is something to make the distinction visible. Plus it
allows us to extend the same useful behaviour to "if" vs "if:".
-David