This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Multiple possible matches for constructor


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]