[PEAK] Re: Variable binding and pattern matching

Paul Moore pf_moore at yahoo.co.uk
Fri Jan 7 14:12:37 EST 2005


"Phillip J. Eby" <pje at telecommunity.com> writes:

>     @something.when("sum_sq < bar*bar", sum_sq="sum(x*x for x in foo)")
>     def do_something((sum_sq,),self,foo,bar):
>         # etc.

This is the variation that looked immediately obvious to me, even
though it doesn't make the binding explicit in any way. The problem
with most of the other variations is that the condition looks like a
little language of its own, which is almost, but not quite like
Python (OK, I know that's actually what it is, but there's no benefit
in rubbing the reader's nose in it :-)) The forms using let...in make
me think of Haskell, which means I end up with two conflicting sets
of language instincts trying to interpret the condition...

> So, does anybody have any thoughts on what syntax looks better for each of 
> these features?  What syntax is more "obvious"?

That was very much a "gut feeling" reaction based on skimming your
post. I haven't used generic functions myself yet, so I may have
missed some important points. Treat it as input from someone who is
*reading* the code, rather than *writing* it.

Paul.
-- 
"Thst's the thing about work, it's something you can throw yourself into and
not worry any more."
"Ah. A bit like a combine harvester, then." -- Tom Holt




More information about the PEAK mailing list