You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea is to support :packer option in pack/2 that defaults to Msgpax.Packer.
This way any default packing can be overwritten with:
defmoduleMyPackerdouseMsgpax.Packerdefpack(value)whenis_float(value)do# pack into 32-bit formatendend
Where use Msgpax.Packer expands to @behaviour Msgpax.Packer and also defines the @before_compile callback that should inject Msgpax.Packer.pack for catch-all clause.
We still need to think how to efficiently pass the user-provided packer into Msgpax.Packer for usage when unpacking collections.
The text was updated successfully, but these errors were encountered:
It seems like a good way to handle it, but I'm not sure I follow all the details. Would this impose a performance hit on every user of the library? My first thought was to always check an option and do a callback, but that's probably too slow. I haven't used @before_compile before. It would be able to (at compile time) add the user defined protocol handler and override the default one?
The idea is to support
:packer
option inpack/2
that defaults toMsgpax.Packer
.This way any default packing can be overwritten with:
Where
use Msgpax.Packer
expands to@behaviour Msgpax.Packer
and also defines the@before_compile
callback that should injectMsgpax.Packer.pack
for catch-all clause.We still need to think how to efficiently pass the user-provided packer into
Msgpax.Packer
for usage when unpacking collections.The text was updated successfully, but these errors were encountered: