On Wed, Sep 03, 2008 at 03:16:00PM -0700, Dennis Lee Bieber wrote: > On Wed, 3 Sep 2008 03:09:18 -0400, Derek Martin <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > struct run { > > int speed; > > direction_type direction; > > }; > > > > Not a function. Describes an action. Sure, you'll probably never see > > this example in a real program. But that doesn't mean you can't do > > it, and it doesn't make it inherently wrong. Someone somewhere might > > very well find a legitimate use case. > > > > Does neither for me... It defines a (physics) VELOCITY (a direction > and a speed, but lacking in starting position and in duration).
OK... so, let me ask you then: I have a computer program that graphs the state of a particular act of running over time t. The only information the program cares about is the speed and direction of that particular instance of running. What would your data structure look like? > An action, "run", would, in my mind require taking this vector and > multiplying it by some duration, and adding the result to some starting > position. I can not be held responsible for your mind... ;-) You're talking about a computational action... which I already said is NOT what I'm talking about. At any given point in time, if someone is running, they have a direction and a speed. The structure I described is sufficient to describe that state. In this extremely silly example, the starting point, end point, and any intermediary positions are not interesting to the problem, which has intentionally been left undefined, because it is an EXAMPLE. Examples are not required to be especially useful or meaningful, and I would guess that the vast majority of examples in, say, introduction to comp sci texts are not (think "hello world"). They need only illustrate something. This particular point was that an object in a computer program can describe some physical action -- in whole or only in part -- without actually needing to have any executable code associated with that state (i.e. it can be a data only, rather than an object with executable methods). The "thing" being described being an action may lend itself to using the name of that action, i.e. a verb, as the name of the object. Though, actually, the example I described above is (minimally) useful. Assuming you had an array of such structs, with say, the index representing the time t in seconds, then it provides you with a graph of the path taken during the act of running. You could superimpose this graph on a map and, given a particular starting point, determine where the person running ended up. You might be inclined to say that the object should be a runner, and you're free to think of it that way if you like... but the fact is the object DOES NOT describe a runner. It describes an instance of running at a moment in time. You might also be inclined to say that the name "run" is a bad choice, because it should be something retarded like state_of_run_at_time_t; but unless you're unbelievably obtuse, then looking at the code, it gets the point across. It may not be the most ideal name, but given the number of times I've seen "foo" used as an identifier in real programs... well, is it really so bad? -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D
pgp0vGu5I07IT.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list