public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Daniel Santos <daniel.santos@pobox.com>
Cc: Allan Sandfeld Jensen <linux@carewolf.com>,
	"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
		Joseph Myers <joseph@codesourcery.com>,
	Richard Henderson <rth@redhat.com>
Subject: Re: [RFC] GCC 8 Project proposal: Extensions supporting C Metaprogramming, pseudo-templates
Date: Wed, 10 May 2017 09:24:00 -0000	[thread overview]
Message-ID: <CAH6eHdReB1QMa8NheTfv_oxDA_8x5M3R9nr9KzrtnQa+nYnWTw@mail.gmail.com> (raw)
In-Reply-To: <58e1ace4-2285-3177-8939-2785c920b888@pobox.com>

On 10 May 2017 at 10:17, Daniel Santos wrote:
> Maybe "constexpr" would be a better name, as it mirrors the C++11 keyword.
> When I first read about C++ getting constexpr, my first thought was, "Yeah,
> as if they needed yet another way to do metaprogramming!" :)  However, I

Because writing functions in normal C++ is much simpler and more
expressive than writing class templates and recursive partial
specializations.

Just because there's already one way to do something doesn't mean
better ways to do it are bad.


> hadn't gone so far as to investigate using this new attribute on functions
> since we already have __attribute__((const)).  I haven't used this before so
> maybe I'm not aware of something that makes it unusable for such cases?
> Which of course raises the question if __attribute__((const)) would work out
> since it's only currently used on function declarations (and pointers to
> function declarations, but I don't fully understand what that is doing in
> handle_const_attribute).

__attribute__((const)) is not a substitute for constexpr, it's not
even in the same ballpark. It says the function doesn't touch global
memory, it doesn't mean its return value is a constant expression, so
you can't do:

int f() __attribute__((const));
int f() { return 1; }
int i[f()];

I don't think __attribute__((const)) is useful for your goal.

  reply	other threads:[~2017-05-10  9:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 23:32 Daniel Santos
2017-05-09  9:36 ` Florian Weimer
2017-05-10  8:46   ` Daniel Santos
2017-05-09 13:29 ` Allan Sandfeld Jensen
2017-05-10  9:13   ` Daniel Santos
2017-05-10  9:24     ` Jonathan Wakely [this message]
2017-05-10 22:09       ` Daniel Santos
2017-05-11 10:12         ` Jonathan Wakely
2017-05-11 10:44           ` Marek Polacek
2017-05-11 14:35           ` Joseph Myers
2017-05-12 20:54             ` Daniel Santos
2017-05-12 21:03               ` Joseph Myers
2017-05-15 11:31               ` Vincent Lefevre
2017-05-12 15:49         ` Martin Sebor
2017-05-12 21:11           ` Daniel Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdReB1QMa8NheTfv_oxDA_8x5M3R9nr9KzrtnQa+nYnWTw@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=daniel.santos@pobox.com \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=linux@carewolf.com \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).