Search code examples
erlang

What does in ? operator/prefix in Erlang mean?


What does the question mark in ?MODULE (which can be seen in all generated code by Mochiweb make command) mean?

-export([start/1, stop/0, loop/2]).

start(Options) ->
    {DocRoot, Options1} = get_option(docroot, Options),
       Loop = fun (Req) ->
               ?MODULE:loop(Req, DocRoot)
       end,
    mochiweb_http:start([{name, ?MODULE}, {loop, Loop} | Options1]).

stop() ->
    mochiweb_http:stop(?MODULE).

loop(Req, DocRoot) ->
    ...

Solution

  • It denotes a preprocessor macro. ?MODULE is one of the predefined macro constants that expand to current module's name.