Thursday, April 18, 2019

Digest for comp.lang.c++@googlegroups.com - 3 updates in 1 topic

Ben Bacarisse <ben.usenet@bsb.me.uk>: Apr 18 09:59PM +0100

> are later identified as #autodec[-1] ... #autodec[-Nn], which allows
> later #autodec portions to be added and they'll automatically insert
> the next value in that location.
 
Yes, you are right, I did. But that part looks even worse. As far as I
can make out you end up with the source code not being the source code,
but I am sure I have missed something. I would advocate for an enum
that can be defined like Go's enums.
 
 
> You're such a hateful person to me, Ben. You said previously in a
> private email that you were going to try to refrain from responding
> to my posts. Please try harder. Your failures are unbecoming.
 
Yes I should. I was filled with the joys of spring and forgot myself.
 
--
Ben.
jacobnavia <jacob@jacob.remcomp.fr>: Apr 18 11:37PM +0200

Le 18/04/2019 à 22:07, Scott Lurndal a écrit :
> function know, a priori, which return code matches which (pre)condition
> failure; particularly when subsequently code gets inserted into the existing set
> such that successive autogenerated return codes are shifted by one?
 
And why are we discussing this brain-dead ideas from this known spammer?
 
Why people here feel happy answering this kind of rubbish?
 
Just looking at this kind of "proposal" for his vaporware leads a sane
reader to deduce that:
 
1) The brain of the poster is malfunctioning badly.
2) He is just posting nonsense, vaguely related to C, to start
"discussions" to cover up his spamming.
 
> Just use a #define, static const uint32_t or enum and update them as needed.
 
That would work, but you forgot something:
 
Before coding (and also before posting rubbish) he should TURN HIS BRAIN
ON...
 
But apparently he can't.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Apr 18 03:51PM -0400

I have a need fairly often to return distinct values for a return value.
I don't particularly care what the values are, but they just need to be
distinct and unique so that if they are returned later I can identify
the exact cause of the error, where it failed.
 
Something like this:
 
int my_function(void)
{
if (!test_condition1)
return -1; // Indicate it failed at this test
 
// Arbitrary code
 
if (!test_condition2)
return -2; // Indicate it failed at this test
 
// Arbitrary code
 
if (!test_condition3)
return -3; // Indicate it failed at this test
 
// If we get here, we're good
}
 
Is there an existing way in C/C++ to automatically create some value
that would allow me to add a new test and have it inject the new
value? Ideally, I'd like for the compiler abilities to be sticky,
meaning once you put in the token/whatever to identify you need a
locally scoped automatically incrementing or decrementing value, that
it bakes it into source code during the compile.
 
Something like coding it this way initially:
 
int my_function(void)
{
if (!test_condition1)
return #autodec; // Indicate it failed at this test
 
if (!test_condition2)
return #autodec; // Indicate it failed at this test
 
if (!test_condition3)
return #autodec; // Indicate it failed at this test
 
// If we get here, we're good
}
 
And during compilation it automatically translates it to this for, baking
in the number:
 
int my_function(void)
{
if (!test_condition1)
return #autodec[-1]; // Indicate it failed at this test
 
if (!test_condition2)
return #autodec_[-2]; // Indicate it failed at this test
 
if (!test_condition3)
return #autodec_[-3]; // Indicate it failed at this test
 
// If we get here, we're good
}
 
This would allow new code to be added later without a hard-value, and
it would automatically adjust to the value inside the scope:
 
int my_function(void)
{
==> if (!test_condition0)
==> return #autodec; // Indicate it failed at this test
 
if (!test_condition1)
return #autodec[-1]; // Indicate it failed at this test
 
if (!test_condition2)
return #autodec_[-2]; // Indicate it failed at this test
 
if (!test_condition3)
return #autodec_[-3]; // Indicate it failed at this test
 
// If we get here, we're good
}
 
It would change to this during compile, and write the source file
back out:
 
if (!test_condition0)
return #autodec[-4]; // Indicate it failed at this test
 
I can see doing this in an external tool, but is there some way to do
it in C/C++?
 
And if not, does anyone have any idea for a good syntax on how to do it?
 
--
Rick C. Hodgin
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: