Just throwing this out there, some modules have the functions present regardless, and return a message or error code saying it isn't implemented if it wasn't compiled in.  So another option is to have all the methods present, and either return a message or error code, or throw an exception, and let the programmer deal with it.

When you think about it, what is easier, to try something, catch the error and try an alternative, or to have an if statement to determine if the first exists and do the alternative if it doesn't.  Really kind of the same thing....

Depends on what we prefer to do, I guess.  Ruby tends to try and rescue (catch) the exception and try something different, but that may just be something preferred by most ruby programmers.


On Thursday, August 28, 2014 4:34 PM, Stephen R. van den Berg <srb@cuci.nl> wrote:


Chris Angelico wrote:
>Topic branch: rosuav/sockopt
>Per Lance's suggestion, I've made a generic setsockopt() function. It
>works only with integers, so it's not suitable for SO_LINGER, which
>therefore should stay the way it is (linger() takes a magic parameter
>of -1), but it works for any of the simple boolean options.

You could add a void|mixed optval second argument which is suitably
interpreted depending on the option at hand.


>I'd rather make it as easy as possible on the Pike code. Which way
>makes more sense?


I would prefer the compile-time checks for efficiency reasons.
--
Stephen.