[erlang-questions] where is os:getuid() ?

Daniel Abrahamsson daniel.abrahamsson@REDACTED
Tue Nov 24 11:50:51 CET 2015


With the risk of sidetracking from the original question...

At a theoretical level, I prefer separating functions implementing
policies, and functions implementing mechanisms. "Mechanism" functions do
one specific thing. There are no exceptions or corner cases. "Policy"
functions, deal with the exceptions. They implement a policy, i.e. they
make a specific decision on how to handle a certain case. As an example,
"platform A has no user concept, so I will always return uid 0, which is
root". Another policy function could implement the policy "platform A has
no user concept, so I will throw an exception". When you confuse, or merge,
the two, you limit the opportunity to implement other policies. If you have
the "mechanism" functions, you can implement whatever policy suits you. If
you only have the policy function, the corner cases are going to bite you
somewhere down the road.

With this reasoning, having a posix module makes sense, because that is a
"mechanism" thing. If I want to implement a generic function that works
similar on both Windows and posix, I can put that in a separate module,
which describes the chosen policy (i.e. the trade-offs made).

getuid is probably not a good example here, because it is likely to make
sense on most, if not all, platforms, but I hope you get the idea.

I hope I didn't side-track the discussion too much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151124/66df9ca5/attachment.htm>


More information about the erlang-questions mailing list