On Thu, 2011-10-13 at 14:04 +0100, Kevin Wright wrote:
[ . . . ]
>
> I'd defy anyone to come up with a dynamically-typed equivalent to this
> Scala snippet that's as simple, comprehensible, and as effortlessly
> thread-safe:
>
>
> val developers = employees collect { case d: Developer => d }
How is this effortlessly thread safe unless each data structure has a
lock and so you have whole data structure locking.
To answer the challenge:
Python:
developers = [ e for e in employees if isinstance(e, Developer) ]
Groovy:
final developers = employees.filter { it instanceof Developer }
which of course gives rise to the problem of what collect, filter, map,
reduce, inject, etc. mean in each language, as each language that has
them uses them with different semantics :-((
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:[email protected]
41 Buckmaster Road m: +44 7770 465 077 xmpp: [email protected]
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part
