All~ On 5/2/05, Uri Guttman <[EMAIL PROTECTED]> wrote: > >>>>> "LW" == Larry Wall <[EMAIL PROTECTED]> writes: > > LW> multi sub opensocket ( > LW> Str +$mode = 'rw', > LW> Str +$encoding = 'auto', > LW> Str [EMAIL PROTECTED]) returns IO; > > and how will that support async (non-blocking) connects? or listen > sockets? i assume this is sorta the replacement for IO::Socket which is > a pure key/value api (except for the shortcut single arg host:port > which is nice to also support). for async you need to provide a callback > in the signature (beyond all the other socket args), an optional timeout > (with its own callback). the callbacks could be defaulted to subs in the > current module/namespace but the coder may also want an OO callback > which needs an object and method. another little optional argument is a > private data field. sure an object callback could handle on a per object > basis. but what if one object wanted to manage multiple async socket > connections? each one needs to be identified in the callbacks which is > what the private data is for. it is passed as an arg to the callback > sub/method.
Currying obviates the need for everything but a sub callback. If you want a callback to a method, curry the object. If you want private data, curry the data. After you are done currying you will have a simple sub to pass in as the callback, the peasants rejoice, and libraries will have a simpler interface. Matt -- "Computer Science is merely the post-Turing Decline of Formal Systems Theory." -???