News for hackers. Stuff that matters.
Re:Amplifying C (2010) by eigenbom on Sunday February 07, 2016 @09:26PM (#11056077)
Always fun to see projects like this, but I don't get some of the motivations. Regarding the code examples:

  // c++
  AutoFile file("c:/temp/foo.txt", "w");
  fprintf(file, "Hello, world");

  // lisp
  (with-open-file (f "c:/temp/foo.txt" "w")
    (fprintf f "Hello, world"))
.. the author thinks the former is cluttered and latter uncluttered (simply because the fprintf is within a sub-scope of with-open-file)? That's a fragile rationale, but you can certainly write c++ that way if you like.
Re:Amplifying C (2010) by nightcracker on Monday February 08, 2016 @02:18AM (#11056773)
If you actually use RAII, and write braces in a bit of an unorthodox style, the distinction disappears even further:

    { AutoFile file("c:/temp/foo.txt", "w");
         fprintf(file, "Hello, world"); }

    (with-open-file (f "c:/temp/foo.txt" "w")
        (fprintf f "Hello, world"))
Re:Amplifying C (2010) by noobermin on Monday February 08, 2016 @06:08PM (#11061646)
I honestly think explicit scopes, even though unorthodox, should become more of a thing. I personally do it in my C play projects to emphasize particular parts in a function as being independent "subordinate clauses", and with variables that only have a limited scope, but not being independent enough to be factored into a function--for example when the clause needs to be within reach of a label.

In C++ with RAII, the "emphasis" makes even more sense, to the extent that it doesn't make things ugly.

Re:Amplifying C (2010) by noobermin on Sunday February 07, 2016 @10:31PM (#11056209)
To be fair, it was written in 2010 back when c++11 was still c++0x and what the final feature set would be was still murky.
Re:Amplifying C (2010) by eigenbom on Monday February 08, 2016 @04:59PM (#11061186)
Ahh, I didn't check the publication date. That explains a bit, c++ has had some big changes in the last 6 years.
Re:Amplifying C (2010) by junke on Monday February 08, 2016 @03:16AM (#11056931)
The motivation is to reach the ultimate state of DRY: skip filling the RAII "template" again and again and use a macro. And yes, you might end up writing a compiler as a side-effect ;-)