[erlang-questions] code:load_binary - why there's module as argument

Attila Rajmund Nohl attila.r.nohl@REDACTED
Mon Apr 16 11:05:19 CEST 2018

2018-04-14 21:11 GMT+02:00 John Doe <donpedrothird@REDACTED>:

> Hi all,
> I wonder why code:load_binary() requires module name as one of the
> arguments? The function would fail if this name is not equal to the real
> module name from the binary, so it can deduce the correct name. Why it does
> not allow loading just whatever module from a given binary and return
> something like {ok, moduleName} as the result?

​I guess to avoid overwriting an unexpected module. The input binary can
contain any code, if it pretends to be the list module, but the caller
thinks its the strings module, that could be a problem.​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180416/aead7391/attachment.htm>

More information about the erlang-questions mailing list