"GMcM" == Gordon McMillan <gmcm@hypernet.com> writes: [please imagine that the c is raised]
BAW> Think about my proposal this way: it actually removes a BAW> restriction. [Jeremy Hylton wrote:]
I think this is really the crux of the matter! The proposal removes a useful restriction.
The alternatives /F suggested seem clearer to me that sticking new attributes on functions and methods. Three things I like about the approach: It affords an opportunity to be very clear about how the attributes are intended to be used. I suspect it would be easier to describe with a static type system.
GMcM> Having to be explicit about the method <-> regex / rule would GMcM> severely damage SPARK's elegance. It would make Tim's doctest GMcM> useless. Do either of these examples modify the __doc__ attribute? I am happy to think of both of them as elegant abuses of the doc string. (Not sure what semantics I mean for "elegant abuse" but not pejorative.) I'm not arguing that we should change the language to prevent them from using doc strings. Fred and I were just talking, and he observed that a variant of Python that included a syntactic mechanism to specify more than one attribute (effectively, a multiple doc string syntax) might be less objectionable than setting arbitrary attributes at runtime. Neither of us could imagine just what that syntax would be.
It prevents confusion and errors that might result from unprincipled use of function attributes.
GMcM> While I'm sure I will be properly shocked and horrified when GMcM> you come up with an example, in my naivety, I can't imagine GMcM> what it will look like ;-). It would look really, really bad ;-). I couldn't think of a good example, so I guess this is a FUD argument. A rough sketch, though, would be a program that assigned attribute X to all functions that were to be used in a certain way. If the assignment is a runtime operation, rather than a syntactic construct that defines a static attribute, it would be possible to accidentally assign attribute X to a function that was not intended to be used that way. This connection between a group of functions and a particular behavior would depend entirely on some runtime magic with settable attributes. Jeremy