The make-recv function in msg.janet creates and returns a receiver function. The receiver function is created such that, as part of its last form, calls unpack:
make-recv takes an optional argument unpack, which if unspecified, defaults to the function string:
(defn make-recv
"Get a function that, when invoked, gets the next message from a readable stream.
Provide an optional unpack function that will parse the received buffer."
[stream &opt unpack]
(def buf @"")
(default unpack string)
It seems that, if make-recv doesn't receive an explicit argument for unpack, unpack would have its default value of string and thus the last form of the receiver function would end up being:
(string (string buf))
Is the inner call to string necessary?
Perhaps it's ok for the last form to be instead:
(unpack buf)
Or is it important that unpack not be passed the buffer?
The
make-recv
function inmsg.janet
creates and returns a receiver function. The receiver function is created such that, as part of its last form, callsunpack
:make-recv
takes an optional argumentunpack
, which if unspecified, defaults to the functionstring
:It seems that, if
make-recv
doesn't receive an explicit argument forunpack
,unpack
would have its default value ofstring
and thus the last form of the receiver function would end up being:Is the inner call to
string
necessary?Perhaps it's ok for the last form to be instead:
Or is it important that
unpack
not be passed the buffer?