V
valentin tihomirov
At that point, it's very easy to write code which does a check-then-
release, check-then-release etc. It's also reasonably easy to make that
exception safe.
If it is so simple to check everything, why then we need to introduce the
exceptions? BTW, check requires extracoding as well as extra processing
power, etc. And you forget that every variable in this approach must be
initialized prior to the checking (and release) .
The answer is we have the exceptions because preparatory work, which adds a
small level of complexity, reduces the automatable work greatly afterwards.
Then you're reusing existing and quite specific terminology to cover
similar situations which aren't exactly the same. That's just a recipe
for miscommunication.
I do not know if the definition of (de-/con-) structor I gave can be more
general. Especially, in the light of C# does not have destructors, as you
mention.
<snip straw man>
Hey, I can come up with straw men too: you like short code? Better use
single letter variables everywhere and have all your code on one line,
right?
No, of course not.
There are times when the shortest code is the most readable. There are
plenty of times when it isn't.
OK, your writing left me under impression that you do not agree with my
examples. Yet, I insist that the real truth, beauty is reaching the goal by
minimal effort. So it is more likely that you should collapse and remove
unnnecessary parst to optimize your expression than moving in contrary
direction.
So you don't believe there's any situation where longer code can be
more readable than shorter code? We'll have to agree to disagree on
that one.
Here's an example: I don't want everyone who ever reads my code to have
to know all of the operator precedence of C#. I'll assume they know
that * binds tighter than + and basics like that, but nothing *very*
complicated - so if there's anything which might introduce confusion in
a reader's mind, I'll put brackets in to make it explicit.
Those brackets are redundant, in that the compiler certainly doesn't
need them - but they help readability.
Do you want to say that calling you J instead of Jon Skeet makes your name
less redundant?
At math classes we were taught to optimize -- that is reduce the number of
operations. For instance, we were required to write 1 instead of 2/2. Later,
we introduced f'(x) to designate the lim(df(x)/dx, dx -> 0) when this
pattern became ubiquitous. Variable name length was not an issue. Yet, I
still often use 't' for time local variables. At object scope I tend to use
a bit more mnemonic names for the parts of the model I build.
Parenthis really add clarity, since operator precedence is not always
evident and is arbitrary sometimes. To resolve the ambiguity, the parensis
are often enforced by compiler, therefore. But in my examples there was no
ambituity as there is none in ternary operator.
I don't understand what you want to be able to do which I didn't just
demonstrate in the example. In my example the message construcvtion
code was not executed - isn't that exactly what you wanted?
The strong man's position is to create multiple executables -- an executable
per macro option. When he will have two independent macros the number of
executables will be m x n. As additional benefit to maintaining multiple
distributions, he precludes himself from dynamically adjusting the macro
options (debug_level). The man is strong because of his preconception -- he
is confident that conventional routines (invocable functions) plus some
attributes can do the job of macros. No, they cannot. Code generators can do
the things which are beyound the code itself. Lazy evaluation is one of
them. Returning from routine by macro is another.