[MacRuby-devel] How to get handle from Dispatch::Source::DATA type source?

Jordan K. Hubbard jkh at apple.com
Wed Jan 20 09:35:08 PST 2010

On Jan 20, 2010, at 7:04 AM, Ernest N. Prabhakar, Ph.D. wrote:

> I actually thought about adding a "file" method on Dispatch::Source that (in cases where you passed in an IO object instead of an file descriptor), would return that object.  Of course it would return nothing in other cases, but maybe that's OK.  Still not sure what to call it -- any suggestions?

Well, frankly, I expected the handle method to return the original handle - that's sort of what the principle of least astonishment would suggest, no?  I could see file as a method which returns the underlying fd, assuming you needed that for some reason, though you should also be able to extract that from handle if it's an IO Object, no?  I'm trying to figure out why you would want anything but the original handle...

> Alternatively, we could only add that method to a subclass of Source, so it only existed when valid.  If we did that, we should probably do the same for the "merge" method on custom sources - but having a subclass with only a single method seems lame.  Maybe implement it in the superclass, but raise an exception if called for an invalid type?

See above - do we really need to go through all that indirection?

- Jordan

More information about the MacRuby-devel mailing list