[Tutor] Re: Not sure how to phrase this question

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Sep 16 20:31:42 EDT 2002


> In short, I want to avoid a lot of named arguments, want to have the
> user interface with "argument smart" classes (in the manner of how I
> think method overloading generally works), going so far as wanting
> positional arguments that are in effect order insensitive.  Give a
> Intersection class a plane and a line in any order and it will know what
> you are trying to get at. No Intersection(plane=planeinstance,
> line=lineinstance). No error on Intersection(planeinstance,lineinstance)
> because the class has be set up to receive only (lineinstance,
> planeinstance).


Hi Arthur,

This link might give some more ideas on doing this kind of generalized
operations.  The code is in Scheme, but the ideas should transfer over
gracefully:

    http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-18.html#%_sec_2.5

Can you give a list of operations that you want to provide as well as
"Intersection"?  Will order always not matter, or are there operations
like 'subtract', where order does matter?  Perhaps your program might be
amendable to a generic-operations approach.


What you're doing sounds reasonable: I think the main problem here is that
it's out of the experience of most mortals!  *grin*


Best of wishes to you!





More information about the Python-list mailing list