From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BCC371F5AE for ; Wed, 22 Jul 2020 20:17:46 +0000 (UTC) Received: from localhost ([::1]:38440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyLBR-0004Nm-I5 for normalperson@yhbt.net; Wed, 22 Jul 2020 16:17:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyLBO-0004Ne-TM for bug-gnulib@gnu.org; Wed, 22 Jul 2020 16:17:42 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:33204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jyLBN-0003t2-9m for bug-gnulib@gnu.org; Wed, 22 Jul 2020 16:17:42 -0400 Received: by mail-pg1-x533.google.com with SMTP id o13so1906295pgf.0 for ; Wed, 22 Jul 2020 13:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=mBuh3Sc0uKxsonfNcSpYcVxVZbVATaZO/27WQGe5A0U=; b=N0Gm5pj4OOaLydsDyDKxGL2rnCBbSdOHOAIh+jnFGA15Jfej9nJXEhHHzSiaT8W6U4 AUqYTx/jp7F1h07yEz/9hqC5nAphmhq32I53AxZ/JpIowgNuh+qWUzubeTwehIqXWuZU ynwYXpE5l9thKm/xnvZV74FXMIrsZ2IHwwqNUrc4K+MH1Eld6fv/OZzjX8doHOIxvOBY uGbhrQXU1jw4wzt8hVsiQgsFbyGILID+ieBK+dPyhe4oidftm29nELHBHSZzdzfb7Bi6 EIg5H1dvyqj1aY4rBxNgTNRO2NOVWTGy4oH8dfdJ+MvLL2c2ZEN73xTWaQ5esyc2W90z U65g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=mBuh3Sc0uKxsonfNcSpYcVxVZbVATaZO/27WQGe5A0U=; b=Xse46aDUuNGW25dVIS2wxSojUhrzLYiHknqA8Gcnsi6FfGLQth5VCZMfEvniEUESbd 86n0Yb1Z0Z3nBSG99sCZYWOl1jpfHTJ3z4VCS4dgOxK8GtwvkyRsuI9n1sDUyBcByniq 0M0O04tfpS0qWjV+pX4/h2GSzcUC3tisW5il3RXSxoChx5N/6BnrjkM6sEStVJ+ecE2i nw8jdKwa5E1U/IC1lHz20FAOHkp8WHT8vfH+YpWIjiyeQ4ZWnwCf6oyAT+bfM73Gh51i t4+mgG2g3re7gNHFWvI+3vqh7uawg5IcUGivI6P3Rxhz0aR19B7jBumQwHXH9Iq83B0G 7cJQ== X-Gm-Message-State: AOAM530Fjs2Owo2E3EkK5sUfykvTmAWOYs+V2hy7Iijoc515JH0OnslD /Obh7TNWoWE3Rcpp3HSN+uPD5UCFR4xR90k1nJ4= X-Google-Smtp-Source: ABdhPJzGsUWNY/2Nnn2tAqMFBXlLJnJS5JP5qHp2MIWUamZ292aQiM8v6TUjxAwkHhs3e6Z1AoY7sombZ2r5TDRbkcw= X-Received: by 2002:a63:af01:: with SMTP id w1mr1340703pge.23.1595449059476; Wed, 22 Jul 2020 13:17:39 -0700 (PDT) MIME-Version: 1.0 References: <2943012.YJjvApnCys@omega> <18494891.EKYmjkQS4y@omega> In-Reply-To: <18494891.EKYmjkQS4y@omega> From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Wed, 22 Jul 2020 22:17:28 +0200 Message-ID: Subject: Re: stack module To: Bruno Haible Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=marc.nieper@gmail.com; helo=mail-pg1-x533.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Am Sa., 23. Mai 2020 um 19:19 Uhr schrieb Bruno Haible : > > Marc Nieper-Wi=C3=9Fkirchen wrote: > > > I was expecting that you write > > > > > > struct > > > { > > > void *base; ... > > > } > > > > This removes type safety. The benefit of the current approach is that > > stack types of different types are not compatible. > > Indeed. Yes, it's a difficult trade-off between debuggability, binary cod= e size, > and type safety... The alternative with the same type safety would be a source file with stack code procedures meant for inclusion (without include guards). The source file would expect a preprocessor defines GL_STACK_NAME, GL_STACK_TYPE, and GL_STACK_EXTERN. The file itself would contain code like the following: #define _GL_STACK_PREFIX(name) _GL_CONCAT(GL_STACK_NAME, _GL_CONCAT(_, name= )) typedef struct { GL_STACK_TYPE *base; size_t size; size_t allocated; } GL_STACK_PREFIX(type); GL_STACK_EXTERN GL_STACK_PREFIX(init) (GL_STACK_PREFIX(type) *stack) { stack->base =3D NULL; stack->size =3D 0; stack->allocated =3D 0; } ... The advantage of this model is that it generalizes to other data structures, for which a sole (or at least simple) macro implementation is not possible. What do you think? Marc