-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compatibility with erlang 18 #10
Conversation
|
||
|
||
compat_now() -> | ||
try erlang:timestamp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If called on an older erlang version, this will result in a call to code_server
. Better to check using erlang:is_builtin(erlang, timestamp, 0)
. Example, using R16B03:
5> try erlang:timestamp() catch error:undef -> undefined end.
(<0.41.0>) call code_server:call(code_server,{ensure_loaded,erlang})
(<0.41.0>) returned from code_server:call/2 -> {module,erlang}
undefined
6> erlang:is_builtin(erlang,timestamp,0).
false
7> erlang:is_builtin(erlang,now,0).
true
@uwiger The |
I think generating code is overkill for this particular problem. I would suggest going with an |
... to clarify, with "next optimization", I didn't mean this PR. :) |
replace erlang:now/0 by erlang:timestamp/0 on Erlang 18 and sup.
@uwiger just pushed a simpler version. Should be good now :) |
Did you push |
never mind - forgot to refresh. |
? mm no I put |
heh np :) |
thanks! |
add compatibility with erlang 18 and sup. use
erlang:timestamp()
instead oferlang:now()