Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This. In the article, Carmack does suggest just this, although its not as explicitly called out.

If your methods are functional, then

    int fancyNumber = calculateFancyNumber();
Can be inclined cleanly/equivalently as:

    int fancyNumber;
    {
        // [Mathy stuff redacted]
        fancyNumber = someIntermediateVariable / anotherIntermediateVariable;
    }


And with c++11 you can use a lambda capture to make it even cleaner (I'm not sure if this is the right syntax)

[&fancyNumber] { // [Mathy stuff redacted] fancyNumber = someIntermediateVariable / anotherIntermediateVariable; }();




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: