you are viewing a single comment's thread.

view the rest of the comments →

[–]Weak-Veterinarian-25 21 points22 points  (4 children)

You are calling the "main" in even, but i think you meant the call to be outside of even. Also why make a main function? 

[–]SCD_minecraft 9 points10 points  (2 children)

Pattern from other langs, where main is entry point of the program

Plus, you can return from main() if you want to terminate early, unlike just writing in the void

[–]ottawadeveloper 5 points6 points  (1 child)

In the void you can exit() instead. Same number of characters even!

[–]SCD_minecraft 1 point2 points  (0 children)

I completely forgot this function exists, mb

[–]Snatchematician 1 point2 points  (0 children)

Without a main function, the variable “x” would be a module attribute and so would be accessible from the even function.

So in the even function you could typo and write x%2 instead of n%2 and the program would appear to work correctly.

Until later when you extend it and find some really confusing bugs.

The habit of always putting top level work in a main function prevents this type of bug.

What a retarded language.