I've read that global variables have a sensible impact on performance.
In order to avoid them I've put everything inside a init function, as I read here.
Simple example, integer.jl:
function __init__()
n = 0
while n < 2
try
print("Insert an integer bigger than 1: ")
n = parse(Int8,readline(STDIN))
catch Error
println("Error!")
end
end
println(n)
end
When I run julia integer.jl
from the command line, nothing happens. function main()
doesn't work either.
What should I do to make it work?
(Also, can you correct any errors, non efficient code or non idiomatic syntax?)
if __name__ == '__main__':
in Python? This is sometimes useful for libraries that also have some kind of standalone debug/testing mode. – Hidalgo