Multiple possible matches for constructor
Mark Wutka
mark@wutka.com
Thu Jan 12 00:09:00 GMT 2006
I was trying to write a little function to open a socket and return an
input port and an output port as values. It seems to work, but
originally I was getting warnings about multiple possibly applicable
methods, since Socket can take InetAddress or String as the first
parameter. The only way I could find to eliminate the warning was to use
(primitive-constructor <java.net.Socket> (<java.lang.String> <int>))
What I am wondering is, does it really matter? The original code that
just called java.net.Socket:new seems to work just fine, I just don't
know if one is any more efficient than the other. Or is there an even
better way to do this?
This is what my function looks like right now:
(define (socket-connect host port)
(let ((s ((primitive-constructor <java.net.Socket> (<java.lang.String> <int>))
host port)))
(values (gnu.mapping.InPort:new (java.net.Socket:getInputStream s))
(gnu.mapping.OutPort:new (java.net.Socket:getOutputStream s)))))
I guess if I leave it the old way, my function can take either String or
InetAddress as a parameter.
Thanks,
Mark
--
Got Love, Joy, Peace, Patience, Kindness, Goodness,
Faithfulness, Gentleness, and Self-control?
More information about the Kawa
mailing list