From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29666 invoked from network); 27 Nov 2023 15:40:43 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 27 Nov 2023 15:40:43 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Mon Nov 27 10:38:29 -0500 2023 Received: from abbatoir (pool-108-6-24-2.nycmny.fios.verizon.net [108.6.24.2]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 7e6c68a6 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Mon, 27 Nov 2023 07:38:26 -0800 (PST) Message-ID: To: 9front@9front.org Date: Mon, 27 Nov 2023 10:38:24 -0500 From: ori@eigenstate.org In-Reply-To: <53a49e38-03e2-4425-bbb7-25e88523153e@invalid.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: interface HTTP over XMPP base CMS scripting dependency-based manager Subject: Re: [9front] [PATCH] Fix assert macro to not break on commas Reply-To: 9front@9front.org Precedence: bulk Quoth Blue-Maned_Hawk : > On 11/26/23 19:00, ori@eigenstate.org wrote: > > Quoth Blue-Maned_Hawk : > >> On 11/26/23 17:52, ori@eigenstate.org wrote: > >>> Quoth Blue-Maned_Hawk : > >>>> What reason have y'all for avoiding macros? > >>> > >>> Well, the fact that you need hacks like the one that started this > >>> thread, for one; > >> > >> I don't see how it's a hack, but maybe i've just become numb to macro > >> shenaniganry. > >> > >>> what if you had macro that took *two* arguments? > >>> > >>> #define assert_msg(cond, msg) \ > >>> ...what here? > >>> > >>> I don't see how you can avoid just saying "it's a macro, it's going > >>> to be weird, don't even try". > >>> > >> > >> Don't even try writing the macro or don't even try making it not weird? > >> Because i can thing of a way to define such a thing: > >> > >> #define assert_msg(cond, msg) ((cond) ? (void)0 : (print(msg), exits(msg))) > >> > >> and i don't think that that's a particularly weird way to do so. > > > > > > Wouldn't that fall apart on the same case that you showed above? > > > > assert_msg((Thing){0, 1}.a, "foo"); > > > > Aye, correct you are. In that case, it could be rearranged to > > #define assert_msg(msg, ...) ((__VA_ARGS__) ? (void)0 : (print(msg), > exits(msg))) > > and it would be able to tolerate unparenthesized commas in the checked > expression. assert_msg((Thing){0, "foo"}.a, (Thing){1, "bar"}.b);