News for hackers. Stuff that matters.
Re:A Programming Language for Games: Demo [video] by ufo on Saturday November 01, 2014 @09:09AM (#8542899)
In functional languages you often see functions like with_file that use a closure to denote the file lifetime:

    with_file(fun file ->
        use_file(file)
    )
I wonder if there is a way to code something similar that works with "defer". This would free you from needing to "remember" to add the defer and would have the advantage of allowing you to use `return` and `break` statements which don't work if you wrap them inside an inner function.

The only thing I can think of is Python's with statement. Since its language syntax it allows for `return` and `break` but I wonder if there is a way to play nice with defer instead of requiring you to use another "block level" syntax construct for every file you use.

Re:A Programming Language for Games: Demo [video] by bjz_ on Saturday November 01, 2014 @09:14AM (#8542921)
We used to do this in Rust, but have found RAII much better for this. Dealing with multiple resources open at once can quickly become painful. See http://blog.skylight.io/rust-means-never-having-to-close-a-s...
Re:A Programming Language for Games: Demo [video] by Too on Saturday November 01, 2014 @09:54AM (#8543023)
Sounds like the finally-keyword in most languages?