call(
window, "draw: %d %d %p", x, y,
alloc("Circle radius: %d color: %u", r, 0xFF0000)
);
That ignores the return value and loses track of the temporary argument.This is all in response to the article claiming you "need to be Bjarne Stroustrup to add OOP to C, but it's a sophomore assignment to add it to Lisp". If I hadn't mentioned the GC, someone else would've jumped on the example for how unpleasant manual memory management is in comparison to Lisp.
> If you're willing to use a garbage collection library [0], you can even have a pleasant syntax for ObjectiveC style OOP in C:
That sounded to me as if you were claiming that GC is a pre-requisite for having a particular syntax. But I gather that's not what you meant. I'm still a little unclear about what you actually meant. You can have memory leaks like the one in your example above in vanilla C without any OOP features at all. GC is completely orthogonal to OOP, and both are completely orthogonal to syntax.
var temp = alloc("Circle radius: %d color: %u", r, 0xFF0000);
var ignored = call(window, "draw: %d %d %p", x, y, temp);
drop(ignored);
drop(temp);
What's a good word for the overall/high level result being less attractive while the low level syntax isn't really the problem? Having a GC does tidy up the code and make it feel high level like Lisp/SmallTalk.