public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Andrew Sutton <andrew.n.sutton@gmail.com>
Cc: Gabriel Dos Reis <gdr@integrable-solutions.net>, gcc-patches@gcc.gnu.org
Subject: Re: [c++-concepts] code review
Date: Thu, 06 Jun 2013 20:29:00 -0000	[thread overview]
Message-ID: <51B0F122.6020301@redhat.com> (raw)
In-Reply-To: <CANq5SystWWs=AOAYAHmRjfx17itDrYQj+GtdUr=-XYGLV_4=6g@mail.gmail.com>

On 06/06/2013 01:47 PM, Andrew Sutton wrote:
> I never did understand why this happens. Compiling with GCC-4.6, I get
> these errors originating in logic.cc from an include of <algorithm>.
> This is what I get:
>
> /usr/include/c++/4.6/cstdlib:76:8: error: attempt to use poisoned "calloc"

Ah, I see: adding the include gets the mentions of malloc in before the 
names are poisoned.  This change is OK.

>>> +; Activate C++ concepts support.
>>> +Variable
>>> +bool flag_concepts
>>
>> You don't need to declare this separately.
>
> I'm not quite sure what you mean. Separately from what?

Separately from

> +C++ ObjC++ Var(flag_concepts, true)

This line declares flag_concepts implicitly.

> That's the long and short of it. Gaby suggested writing constraints
> here so that, for any instantiation, you would have easy access to the
> constraints for that declaration.

I'm not sure why you would care about the constraints for a particular 
instantiation; constraints only apply to the template, right?

> branch_goal queues a copy of the current sub-goal, returning a
> reference to that new branch. The insertion of the operands are done
> on different sub-goals, giving the expected results.

Right, I suppose I should have paid more attention to "This does not 
update the current goal"...

>>> +template<typename F>
>>> +  tree
>>> +  extract_goals (proof_state& s, F proj)
>>
>> Why is proj a function argument rather than a template argument, which would
>> allow inlining?
>
> STL influence. Can you give an example of how this should look in
> order to take advantage of inlining?

I was thinking something like

template<term_list& (*proj)(proof_goal&)>
tree
extract_goals (proof_state& s)
...
  return extract_goals<assumptions>(s);

but I suppose STL style is OK, too.

> It was used in a previous version, and I suspect it might be useful in
> the future, but I'm not 100% sure. I felt it would be worthwhile to
> keep it in the patch just in case.

Makes sense.

>> And why do it this way
>> rather than check and possibly return at the top of the function, as
>> elsewhere in the parser?  You already have cp_parser_requires_clause
>> checking for RID_REQUIRES.
>
> I was trying to write the parsing code a little more modularly so I
> could keep my parse functions as small as possible. I use the facility
> more heavily in the requires/validexpr code that's not included here.

Hmm, to me it seems more modular to keep all of the code for handling 
e.g. "requires" in its own function rather than needing two different 
places to know how a requires clause starts.

>> Why don't you use 'release' and conjoin_requirements here?
>
> Because there is no template parameter list that can provide
> additional requirements in this declaration.

OK, please add a comment to that effect.

>>> +// Try to substitute ARGS into PARMS, returning the actual list of
>>> +// arguments that have been substituted. If ARGS cannot be substituted,
>>> +// return error_mark_node.
>>
>> The comment sounds more like tsubst_template_parms than
>> coerce_template_parms.
>
> It might be... I'll have to look. What I actually want to get is the
> set of actual arguments that will be substituted for template
> parameters given an initial set of arguments (lookup default
> arguments, generate pack arguments, etc).

Right, I think coerce_template_parms has the effect you want, I just 
don't think of it as doing substitution, so the comment and name could 
use a tweak.  If the function doesn't go away, that is.

Jason

  reply	other threads:[~2013-06-06 20:29 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28 14:07 [c++-concepts] Reserving new keywords for concepts Andrew Sutton
2013-02-28 14:51 ` Gabriel Dos Reis
2013-02-28 15:01   ` Andrew Sutton
2013-02-28 15:11     ` Gabriel Dos Reis
2013-02-28 15:54       ` Andrew Sutton
2013-02-28 15:57         ` Gabriel Dos Reis
2013-06-06 15:55   ` [c++-concepts] code review Jason Merrill
2013-06-06 17:48     ` Andrew Sutton
2013-06-06 20:29       ` Jason Merrill [this message]
2013-06-08 13:35         ` Andrew Sutton
2013-06-10  0:49           ` Gabriel Dos Reis
2013-06-10 16:27             ` Jason Merrill
2013-06-10 19:30           ` Jason Merrill
2013-06-11 13:45             ` Andrew Sutton
2013-06-11 14:27               ` Jason Merrill
2013-06-11 14:49                 ` Andrew Sutton
2013-06-11 15:00                   ` Jason Merrill
2013-06-11 15:09                     ` Andrew Sutton
2013-06-11 17:54                       ` Jason Merrill
2013-06-12 15:53             ` Gabriel Dos Reis
2013-06-12 16:35               ` Jason Merrill
2013-06-14 15:32                 ` Andrew Sutton
2013-06-15  1:40                   ` Jason Merrill
2013-06-15  2:13                     ` Gabriel Dos Reis
2013-06-17 18:11                     ` Andrew Sutton
2013-06-17 19:20                       ` Jason Merrill
2013-06-18  0:29                         ` Gabriel Dos Reis
2013-06-18 16:28                         ` Andrew Sutton
2013-06-19 14:21                           ` Jason Merrill
2013-06-19 16:10                             ` Andrew Sutton
2013-06-20  5:30                             ` Gabriel Dos Reis
2013-06-20 13:01                               ` Jason Merrill
2013-06-20 13:09                                 ` Gabriel Dos Reis
2013-06-20 13:19                                   ` Andrew Sutton
2013-06-20 13:57                                     ` Jason Merrill
2013-06-20 14:18                                       ` Andrew Sutton
2013-06-20 15:17                                         ` Jason Merrill
2013-06-20 15:22                                           ` Gabriel Dos Reis
2013-06-20 15:27                                             ` Jason Merrill
2013-06-20 15:29                                               ` Gabriel Dos Reis
2013-06-20 15:50                                           ` Andrew Sutton
2013-06-20 17:23                                             ` Jason Merrill
2013-06-20 18:33                                               ` Jason Merrill
2013-06-21 12:46                                                 ` Andrew Sutton
2013-06-24 15:55                                                   ` Jason Merrill
2013-06-20 15:20                                     ` Gabriel Dos Reis
2013-06-09 20:34         ` Oleg Endo
2013-06-10  0:34           ` Gabriel Dos Reis
2013-06-10 14:51             ` Diego Novillo
2013-06-10 22:51               ` Lawrence Crowl
2013-06-10 16:14             ` Jason Merrill
2015-05-01 18:32 Jason Merrill
2015-05-01 19:21 ` Andrew Sutton
2015-05-08 20:08 ` Andrew Sutton

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=51B0F122.6020301@redhat.com \
    --to=jason@redhat.com \
    --cc=andrew.n.sutton@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    /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).