From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 128373858D35 for ; Thu, 29 Dec 2022 15:37:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 128373858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102c.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so19283117pjd.0 for ; Thu, 29 Dec 2022 07:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Lx51wmod28h49UVFghOgsyU4jJ0NIe5JyNsrlwi2Tbk=; b=pZMjMgyNwRuQbWm+0GyiqYsiKRkcT7uNy/F9vzh2jCjmS6yvVuboInygX29oVPjUhe m6Ed0e4Pho6FXiKFt/q1HwVEImNshwJISDD/mkHyVQnVq/5rAe6YEfhDv+wTJ0P/7Sge wwOeqitlCDwkVaaxJkWWmR2i12cShwKg8RxLg6J1cRgDa7E+onms9S/3GuFIETw1BnRr b3C1JjBF8V/fJ04wzqOswCNTAhygYxpwPUsPn5w8O9wlhtLKzSa2eA/0fB1XZ6HwpexM Au12y8V0N9CIrwg2F37p6Y2ZQKoF7JxEx7eGG7x6poDKEiEXy5vtGpUYgR3sQssLhfS6 xyIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Lx51wmod28h49UVFghOgsyU4jJ0NIe5JyNsrlwi2Tbk=; b=vscwr+98IuK7Q2TUqJ/gzLKAbzVA66+OUn4OiCYsBMVbBcZNKvRNfZ9RyR2wIElm9y ZsCGpl0W8EGAH0KfN06JCMHfSjk3DOTj4FVrxh1xPpwgFx55NQOfcBP8Xrlntd2SUQcd zHmF/H/8/OPwZr/6ePjBYYQNhJLaaKyVnEhtkwn/MhxUP3o1AmY6ZuKlg2w/N3KLg4qR qavhLcJt71E5sHQG9P8DadhAVAEIgf7ZT+hjHjz2yM5Z5HfbcQyj/Ko4bBANTql0fTjS bDdRUywn/CBRQ5JA1Io0Z60jzpcdIQrRCmte9HJV+wsx9kNCuKzqsCWEB0dcBJVn1zPC 3m9g== X-Gm-Message-State: AFqh2kqNQg/NJ9VVVMnE2nkAB49i5ZV7PRZWuzzS5T1sFQ98bl5+8+Yy AQ2tB0j8jPzLB211ggOK8ePpxlfbVomQz/ToyUM/Db9ihfY= X-Google-Smtp-Source: AMrXdXu9UDvYs2PYqv1JymUThr72QSF7XBXYhzvvVyIHNQ+KMcafhVi4emo78lSq2uKk3jb/gfsIuWXy6cretVSHuvg= X-Received: by 2002:a17:902:6b82:b0:192:7f35:90ee with SMTP id p2-20020a1709026b8200b001927f3590eemr584942plk.20.1672328271525; Thu, 29 Dec 2022 07:37:51 -0800 (PST) MIME-Version: 1.0 From: Gavin Ray Date: Thu, 29 Dec 2022 10:37:40 -0500 Message-ID: Subject: Difficulty in implementing a GCC plugin for [[invariant]] contract functions in classes/structs without prior experience? To: gcc@gcc.gnu.org Content-Type: multipart/alternative; boundary="000000000000927d4e05f0f94475" X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000927d4e05f0f94475 Content-Type: text/plain; charset="UTF-8" Hey all, The feature I appreciate most about the D programming language is its "Design by Contract" feature. Contract programming - Dlang Tour With the recent merge of Contracts to GCC master, C++ comes close to this, with support for function-based contracts. The most powerful contract though, is the "invariant" contract: *invariant() is a special member function of struct and class types that > allows sanity checking an object's state during its whole lifetime:* > > *- invariant() is called after the constructor has run and before the > destructor is called.* > *- invariant() is called before entering a member function* > *- invariant() is called after exiting a member function.**- Class > invariants are inherited. That means that a derived class invariant will > implicitly call the base class invariant.* I'm very interested in prototyping a GCC plugin to implement support for transforming all member function calls in class/struct types such that a call to the [[invariant]]-annotated function (if any) is placed at the beginning and end of method bodies. Does anyone have any idea whether something like this would be suitable for a first plugin, or if there would be roadblocks/technical challenges to implementing such a thing? I'd be grateful for any advice. Thank you, Gavin =) --000000000000927d4e05f0f94475--