Uphill
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 1 11:54:16 PDT 2015
On Monday, 1 June 2015 at 17:17:18 UTC, Ola Fosheim Grøstad wrote:
> On Monday, 1 June 2015 at 16:57:00 UTC, Jonathan M Davis wrote:
>> I use macros for stuff like exceptions all the time - e.g.
>>
>> THROW(MyException, ("This value is wrong: %d", foo));
>
> ick! Yes, if you want stack-trace like information in
> release-builds you need to use the macro system, but that's
> because __FILE__ and __LINE__ are macros! That's a C deficiency.
> Usually your debugger gets you what you are looking for
> without this in debug builds, right?
Goodness no. The exception needs to have that information in it,
and I want exceptions logged so that I can track what happened
without running in a debugger - and in release mode as well as
debug mode. And it's not like I can necessarily reproduce the
problem by rerunning the program anyway, so relying on the
debugger for this sort of thing just doesn't fly in general, much
as it might in simple cases.
> (I don't use exceptions in C++)
My condolences.
> It's a problem if you need it. It is almost always used to
> address language design flaws or other structural flaws.
Even if that's true, you're still stuck unless they fix the
language. If/until C++ provides alternate solutions to the kinds
of things that require macros right now, you need macros. I can
always wish that C++ were better, but if I'm programming in C++,
I have to deal with what it provides. The only way around that is
to use another language (like D), and it that were an option, I
probably wouldn't be using C++ in the first place.
It sounds to me like you're too against macros for your own good.
Sure, they suck, but that's just life with C++ unless you want to
make life harder for yourself. Simply wishing that the situation
were better doesn't make it so.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list