"Stephen R. van den Berg" srb@cuci.nl wrote:
I now have a cmod which is in a subdir src/post_modules/USB, which gives me an USB.devices(), USB.Iterator(), USB.device() and USB.transfer().
I take it that neither USB.devices nor USB.device are objects, since they start with lowercase. What are the names of the objects that represent them?
Now, what if I'd like it to start with:
object dev=USB();
(and then the rest with foreach() etc. same as above).
Are there any aesthetical or technical reasons not to prefer this?
Well, I have a designwise reason: It's confusing. USB is the module, but what you get there is some object inside the module. Using `() directly on the module makes it appear to be an object, but the object and the module are really two different things, and it's less confusing if they are kept separate, and that the separation remains clear.
If there are no obvious objections, what would be the easiest way to implement this? Is this doable in the cmod?
It should be simple to do with an `(), even in a cmod afaik.
Are there any existing modules that did it this way?
There is an experiment in lib/modules/Threads.pmod which tries to unify the Thread module with the Thread.Thread objects. There you can see some effects of trying to do that, and I've also left a fairly lengthy critical comment on why it's not such a great idea.
I'm not implying that's what you're trying to do here, though - from the looks of it you may be aiming only at a simple shortcut. But even so my argument earlier remains applicable.