Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #139400
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c, comp.lang.c++ |
| Subject | Re: if cargo blocks |
| Followup-To | comp.lang.c++ |
| Date | Fri, 4 Jan 2019 11:10:36 +1300 |
| Lines | 48 |
| Message-ID | <g97fitFffefU2@mid.individual.net> (permalink) |
| References | <q084io$qe1$1@dont-email.me> <g94mhaFffefU1@mid.individual.net> <q0j8b3$qt7$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net eiIIxO3Xs1PeAV2K9I1dgQrtPn6Tns/VjNg58qJov7/eEbRDxF |
| Cancel-Lock | sha1:oNeKOtSZcyL+OsHjBmn+4FGKNIQ= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
| In-Reply-To | <q0j8b3$qt7$1@dont-email.me> |
| Content-Language | en-US |
| Xref | csiph.com comp.lang.c:139400 comp.lang.c++:62756 |
Cross-posted to 2 groups.
Followups directed to: comp.lang.c++
Show key headers only | View raw
On 03/01/2019 09:54, Rick C. Hodgin wrote:
> On 1/2/2019 3:50 PM, Ian Collins wrote:
>> On 30/12/2018 04:42, Rick C. Hodgin wrote:
>>> I've had the idea for an "if cargo" block. It is a standard if {}
>>> block, but one containing additional cargo prefixed by in, out, and
>>> enter keywords, to be contained within each if clause to run before,
>>> after, and when entering the if statement.
>>>
>>> The enter clause is given specifically to relate to something that
>>> should be done, possibly to undo something done in the in clause,
>>> including possibly calling the out clause to undo that setup, and
>>> prepare it for whatever other code is needed within the block.
>>
>> Why are proposing (at lest in c.l.c++) an unpleasant replacement for
>> something the language already supports?
>
> I am unaware of its existence. Enlighten me, sir Ian.
Fibble as already answered this in his own inimitable style.
Something like this will do what you want in C++:
void f(bool some_test1)
{
struct T1
{
bool cleaned {};
T1() {} // setup_for_test1
~T1() { if (!cleaned) cleanup(); } // cleanup_for_test1
void related_code_if_block_entered() {}
void cleanup() { cleaned = true; }
};
T1 t1;
if (some_test1)
{
t1.related_code_if_block_entered();
// Code1 here for this test passing
}
else
{
t1.cleanup();
}
}
--
Ian.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 10:42 -0500
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-29 17:26 +0100
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-29 16:32 +0000
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-29 16:56 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 12:34 -0500
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-29 23:49 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:52 -0500
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-30 00:12 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 19:04 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-30 06:12 +0100
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-30 15:23 +0100
Language (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2018-12-30 15:39 +0000
Re: Language (Was: if cargo blocks) rbowman <bowman@montana.com> - 2018-12-30 11:23 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-31 05:21 +0100
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-31 18:09 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 12:22 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 12:04 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 11:50 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 11:43 +0100
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 14:27 +0100
German grammar (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-01 14:17 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 11:04 -0700
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-01 10:38 -0800
Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 10:57 -0700
DDR Ralf Goertz <me@myprovider.invalid> - 2019-01-01 21:18 +0100
Re: DDR rbowman <bowman@montana.com> - 2019-01-01 16:18 -0700
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2019-01-01 16:30 -0800
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-30 11:09 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-31 05:43 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 12:06 -0700
Linguistics. Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2019-01-01 16:27 -0800
Re: Linguistics. Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 22:30 -0700
Re: Linguistics. Re: if cargo blocks Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2019-01-02 04:18 -0700
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-30 02:07 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 21:59 -0500
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 13:57 -0700
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 16:03 -0500
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-29 21:32 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 16:06 -0700
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:15 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:32 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:34 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:38 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 15:40 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:45 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:36 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:42 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 15:45 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:54 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:58 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 16:01 -0800
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-29 13:36 -0800
Re: if cargo blocks "I Set My Girlfriend's Pantyhose on Fire" <cdalten@gmail.com> - 2018-12-29 13:16 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 16:32 -0500
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2018-12-30 13:00 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 16:12 -0500
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2018-12-30 13:31 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 16:45 -0500
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-30 22:17 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 17:22 -0500
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 20:25 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-03 09:50 +1300
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-02 15:54 -0500
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-02 16:29 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 00:44 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 08:17 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 05:40 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 09:15 -0500
You are so full of shit (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-03 13:42 +0000
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-03 12:27 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-04 11:11 +1300
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2019-01-03 14:37 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 17:48 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-03 14:59 -0800
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 00:44 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 08:19 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 05:43 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 05:51 -0800
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2019-01-03 13:22 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-04 11:10 +1300
csiph-web