"Peter Haworth" <[EMAIL PROTECTED]> writes: > [Apologies if you see this as a duplicate. I sent the original to perl6-all by >mistake] > > On Thu, 08 Nov 2001 11:10:43 +0000, Piers Cawley wrote: >> I keep coming back to the ruby/smalltalk >> block approach >> >> &assert_with_func := { >> | &^sub is constant, $^expected is constant, $^got, $message | >> &^sub($^expected, $^got, $message); >> }; >> >> Note that the suggested syntax is merely a 'port' from Ruby. I've not >> really considered whether this syntax would fit well with perl. The >> first | is reasonably obvious, but I'm not sure we can reliably spot >> the closing one. > > I remember fretting about the same thing when I wrote a Smalltalk parser, > and being surprised when it turned out not to be an issue. I think this was > due to the limited kinds of expressions Smalltalk allows, but it was over a > decade ago, and my memory may be faulty. > > Anyway, couldn't you say this? > > &assert_wth_func := > sub(&^sub is constant, $^expected is constant, $^got, $message){ > &^sub($^expected, $^got, $message); > }; > > I'm not sure if that still curries appropriately, though.
If currying magic works in subroutine parameter strings then you can just do sub assert_with_func (&^sub is constant, $^expected is constant, $^got, $message) { &^sub($expected, $got) or die $message || $default_message; } Here's hoping it will work. -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?