[erlang-patches] exporting a new function in prim_file.erl

Robert Virding rvirding@REDACTED
Wed Apr 21 18:26:57 CEST 2010


Hi Filipe,

On 21 April 2010 18:18, Filipe David Manana <fdmanana@REDACTED> wrote:
> Hello,
>
> I'm trying to add a new function to prim_file.erl that will be called by
> file_io_server.erl. Therefore I export it in the first export macro.
>
> This new function happens to have exactly the same interface (arity and arg
> type, return values) as prim_file:sync/1, so I copied the sync function
> clause, renamed it, and added the corresponding export.
>
> After building and installing OTP, I get an error when calling
> file:my_func/1:
>
> =ERROR REPORT==== 21-Apr-2010::16:30:53 ===
> Error in process <0.35.0> with exit value:
> {undef,[{prim_file,my_func[{file_descriptor,prim_file,{#Port<0.500>,7}}]},{file_io_server,file_request,2},{file_io_server,server_loop,1}]}
>
> file:my_func/1 just calls file_io_server:my_func/1 wich in turn calls
> prim_file:my_func/1.
>
> It seems that prim_file is not exporting  my_func. Yet I have an explicit
> "-define([... sync/1 my_func/1 ...])."

This, -define, is used to define macros, not for exporting functions
from a module. It should be:

-export(([... sync/1 my_func/1 ...]).

There is an export declaration already which exports the old
functions. It is perfectly ok to have many export declaration, I use
that to cluster various "classes" of exported functions.

Robert


More information about the erlang-patches mailing list