Multiple SAMs for same concept
Lawrence Kesteloot
lk at teamten.com
Thu Jul 15 20:34:26 PDT 2010
On Thu, Jul 15, 2010 at 5:56 PM, Reinier Zwitserloot
<reinier at zwitserloot.com> wrote:
> HashMap and Hashtable both
> implement the same interface, both do so entirely correctly, and yet they
> aren't compatible with each other in some regard - in this case, null
> keys/values.
Exactly, and if a function took a Map object it would know to defend
itself against null keys and values (for example, by not blindly
calling toString() on either). But imagine a signature-compatible
NonNullMap interface and some syntactic sugar that allowed developers
to trivially autowrap objects from one to the other. It'd be too easy
to send an object into a method that violated the contract of the
parameter.
In any case, I think we agree that it shouldn't be completely
transparent, which is what I was objecting to. The variant with only #
appended is Perl-like magic noise to me, but I always prefer
explicitness at the expense of terseness.
(We need a variant of Godwin's Law: "As an online programming
language discussion grows longer, the probability of a comparison
involving Perl approaches 1, and the person who brings it up has
lost.")
Lawrence
More information about the lambda-dev
mailing list