At 18:15 2003-01-22 +0100, Thomas Heller wrote:
Boyd Roberts <boyd@strakt.com> writes:
Thomas Heller wrote:
I don't think so. For me, this is a fine implementation of chr():
def chr(i): return "\x00\x01\x02x03...\xFF"[i]
That's dreadful.
def chr(i): return'%c' % i
Maybe, but you probably got my point...
I see four issues in the above that might be worth some guiding words from the leaders[a]: 1) premature optimization, 2)appropriate level of Python code for coding PyPython, 3) appropriate definition semantics, 4) dependencies in definitions. 1) Standard advice, presumably 2) What kinds of constructs will be best for Psyco to deal with? When coding the definition of something, should one ask: 2a) Is the thing being coded part of core minimal PyPython, so coding should be limited to a Python subset, or 2b) Is the thing being coded at the next level, so that the full language can be presumed to be available? 2c) How does one know whether a thing belongs to 2a or 2b, or is this distinction really necessary in the current thinking? 3) When is it good to define primitively, like Thomas's definition, and when is it good to define in terms of a composition implicitly delegating to existing function(s), like Boyd's? And should one be careful as to whether the functions one is depending on belong to 2a or 2b? 4) Should a dependency tree be documented as we go, e.g., to avoid hidden circular dependencies in delegated functionality, but also to make clear levels of primitiveness? (BTW, ISTM this would help in any future attempt to factor out the implementation of a primitive core functionality). The two definitions of chr() above are examples of primitive vs composite/delegating definitions, which is what brought this to mind (which is not to say that the "primitive" definition doesn't depend on anything, but it's composing with lower level primitives). Regards, Bengt [a] Should I have cc'd Armin, Chris, and Holger? I.e., would that have been courtesy or redundant annoyance?