Globals are not a great way to do this. Typically you'd make an object which 
holds all your fields, and then pass that object around. It's pretty much the 
same thing you'd do in Python, just that procedures don't belong to the object, 
they simply take this object as the first parameter. Because Nim has UFCS you 
can also call any function with its first argument before the call, similar to 
what you would do in an object-oriented language.
    
    
    stdout.writeLine("Hello world") # Is the same as:
    writeLine(stdout, "Hello world") # and also:
    stdout.writeLine "Hello world"
    
    
    Run

This way you get the best of both worlds.

Reply via email to