Ian Bicking: the old part of his blog

PEP 246, as-a

Alex Martelli has created a new draft of PEP 246: Object Adaptation. There's a thread on python-dev. Most of the discussion centers around two points, but I'll let you read the thread to find out what those points are. (A hint: the actual debate is a little boring)

Anyway, while reading I came upon this post from Phillip Eby that had a good quote, talking about an aspect of interfaces and adaptation:

IOW, adaptation is all about "as a" relationships from concrete objects to abstract roles, and between abstract roles. Although one may colloquially speak of using a screwdriver "as a" hammer, this is not the case in adaptation. One may use a screwdriver "as a" pounder-of-nails. The difference is that a hammer might also be usable "as a" remover-of-nails. Therefore, there is no general "as a" relationship between pounder-of-nails and remover-of-nails, even though a hammer is usable "as" either one. Thus, it does not make sense to say that a screwdriver is usable "as a" hammer, because this would imply it's also usable to remove nails.
Created 12 Jan '05

Comments:

Ironic. I understand that quote perfectly well, but only as long as I forget nearly everything I know about hammers and screwdrivers. No problem there, but for the record:

  1. a certain kind of hammer (the claw hammer) can also be used to remove nails (the claw end being the business end in this case); ball-peen hammers, sledge hammers, and various assorted mallets have proven themselves, time and again, ineffective in removing nails. Let's not even imagine jack hammers and steam hammers in the nail removal scenario.
  2. screwdrivers (flat-bladed screwdrivers, anyway) can be used to remove nails with delightful results, and it makes perfect sense to say so.

There's probably some philosophical point to be made here, but its general statement escapes me.

# Jud Carpenter