Skip to content

Instantly share code, notes, and snippets.

@mprymek
Created March 9, 2015 11:58
Show Gist options
  • Save mprymek/3302ff9d13fb014b921b to your computer and use it in GitHub Desktop.
Save mprymek/3302ff9d13fb014b921b to your computer and use it in GitHub Desktop.
-module(my_module).
% Eshell V6.3 (abort with ^G)
% 1> c("my_module.erl").
% {ok,my_module}
% 2> my_module:f().
% Public!
% ok
% 3> my_module:f_private().
% ** exception error: undefined function my_module:f_private/0
% 4> my_module:g().
% Public!
% ok
% 5> my_module:h().
% Public!
% ok
% 6> my_module:i().
% Public!
% ok
% 7> my_module:j().
% Private!
% ok
% 8> my_module:k().
% ** exception error: undefined function my_module:f_private/0
% 9> my_module:l().
% ** exception error: undefined function my_module:f_private/0
% 10> my_module:m().
% ** exception error: undefined function my_module:nonexistent/0
-export([f/0,g/0,h/0,i/0,j/0,k/0,l/0,m/0]).
f() ->
io:format("Public!\n").
f_private() ->
io:format("Private!\n").
g() ->
f().
h() ->
my_module:f().
i() ->
apply(my_module,f,[]).
j() ->
f_private().
k() ->
my_module:f_private().
l() ->
apply(my_module,f_private,[]).
% this would raise compile error
% m() ->
% nonexistent().
% This does NOT raise compile error!
m() ->
my_module:nonexistent().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment