public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: is_predicate_p?
@ 2002-06-08  3:20 Robert Dewar
  2002-06-08  3:48 ` is_predicate_p? Jason Merrill
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Dewar @ 2002-06-08  3:20 UTC (permalink / raw)
  To: gcc, jason

> Predicates in GCC come in a wide variety of spellings.  Some end in _p,
> some start with is_, some have _is_ in the middle, some just expect you to
> know they're predicates based on the meaning of the name.  Should we set
> some sort of standard spelling for future additions?

I would have guidelines rather than a standard here. I would avoid the use
of _p unless you do decide to standardize on this (which seems very dubious
to me). The use of _p is simply not intuitive. All the other three cases
sound plausible to me, and I would hesitate to mandate any one over the others.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08  3:20 is_predicate_p? Robert Dewar
@ 2002-06-08  3:48 ` Jason Merrill
  0 siblings, 0 replies; 19+ messages in thread
From: Jason Merrill @ 2002-06-08  3:48 UTC (permalink / raw)
  To: Robert Dewar; +Cc: gcc

>>>>> "Robert" == Robert Dewar <dewar@gnat.com> writes:

>> Predicates in GCC come in a wide variety of spellings.  Some end in _p,
>> some start with is_, some have _is_ in the middle, some just expect you to
>> know they're predicates based on the meaning of the name.  Should we set
>> some sort of standard spelling for future additions?

> I would have guidelines rather than a standard here. I would avoid the use
> of _p unless you do decide to standardize on this (which seems very dubious
> to me). The use of _p is simply not intuitive. All the other three cases
> sound plausible to me, and I would hesitate to mandate any one over the others.

_p is intuitive to folks coming from a Lisp background, including those of
us who were indoctrinated into the Emacs cult at an early age.  But since
this code has little to do with Lisp, I agree that it is probably the wrong
choice.  It does have a significant representation in the current sources,
though; try a grep of rtl.h.

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-09 13:49 is_predicate_p? Robert Dewar
@ 2002-06-09 14:59 ` Daniel Jacobowitz
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Jacobowitz @ 2002-06-09 14:59 UTC (permalink / raw)
  To: Robert Dewar; +Cc: nathan, dnovillo, gcc, gdr, jason

On Sun, Jun 09, 2002 at 04:27:29PM -0400, Robert Dewar wrote:
> <<call, it'll always be
>         if (is_foo ())
> >>
> 
> Yes, and by your same argument if I write
> 
>    if (stmt_ends_bb (foo))
> 
> it is also pretty obvious that this a predicate

Maybe... it could just as easily be returning a bb* to the block that
foo ends or NULL in some exceptional error condition.  I'm in favor of
some (any; I don't care) consistence naming convention for all
predicate functions.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
@ 2002-06-09 13:49 Robert Dewar
  2002-06-09 14:59 ` is_predicate_p? Daniel Jacobowitz
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Dewar @ 2002-06-09 13:49 UTC (permalink / raw)
  To: dewar, nathan; +Cc: dnovillo, gcc, gdr, jason

<<call, it'll always be
        if (is_foo ())
>>

Yes, and by your same argument if I write

   if (stmt_ends_bb (foo))

it is also pretty obvious that this a predicate

<<No. I now can't tell whether stmt_ends_bb (foo) is commanding that foo
end a statement, or questioning whether foo ends a statment.
>>

I would find stmt_ends_bb a very poor choice of name for the command. I find
it a well chosen name for the predicate. For the command I would use
something like require_end_bb or ensure_end_bb or some such

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-09 10:15 is_predicate_p? Robert Dewar
  2002-06-09 12:57 ` is_predicate_p? Diego Novillo
@ 2002-06-09 13:00 ` Nathan Sidwell
  1 sibling, 0 replies; 19+ messages in thread
From: Nathan Sidwell @ 2002-06-09 13:00 UTC (permalink / raw)
  To: Robert Dewar; +Cc: dnovillo, gcc, jason, gdr


Diego Novillo wrote:
> <<I personally tend to use is_foo for adjectives (e.g.,
> is_binary_expr) and foo_p for verbs (e.g., stmt_ends_bb_p).
I'd think of 'binary_expr' as a noun, and as we all know nouns
and verbs are somewhat interchangable. I would have great
difficulty with is_noun and verb_p. Are you thinking of foo
as a property the object has collected (is_noun), or as
a process it has undergone (verb_p)? They're pretty inter-
changable, why make them different?

Robert Dewar wrote:
> But the _p here seems gratuitous, stmt_ends_bb is a perfectly reasonable
> name for a predicate and reads just fine.
No. I now can't tell whether stmt_ends_bb (foo) is commanding that foo
end a statement, or questioning whether foo ends a statment.
Now sometimes it's obvious and sometimes it's not, but I think
we should have some convention to mark predicate functions, it makes
intent more obvious.

Diego Novillo wrote:
> We also have uses of _p for pointers.  If we are going to use a
> new convention I would rather get rid of _p entirely.
good point, I'd not noticed those typedefs (they appear confined
to gentype). Perhaps is_ is better because of that, and as Gaby
points out, you'll never see a naked
	is_foo ()
call, it'll always be
	if (is_foo ())
which I think is pretty damn obvious. 

I have been persuaded by the arguments that is_ is better than _p.
oh, and I was wrong, the spanish version should be is_foo_si ;-)

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-09 10:15 is_predicate_p? Robert Dewar
@ 2002-06-09 12:57 ` Diego Novillo
  2002-06-09 13:00 ` is_predicate_p? Nathan Sidwell
  1 sibling, 0 replies; 19+ messages in thread
From: Diego Novillo @ 2002-06-09 12:57 UTC (permalink / raw)
  To: Robert Dewar; +Cc: nathan, gcc, jason

On Sun, 09 Jun 2002, Robert Dewar wrote:

> <<I personally tend to use is_foo for adjectives (e.g.,
> is_binary_expr) and foo_p for verbs (e.g., stmt_ends_bb_p).
> >>
> 
> But the _p here seems gratuitous, stmt_ends_bb is a perfectly reasonable
> name for a predicate and reads just fine.
>
Right, hence my conclusion that we should probably get rid of the
_p suffix.


Diego.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
@ 2002-06-09 10:15 Robert Dewar
  2002-06-09 12:57 ` is_predicate_p? Diego Novillo
  2002-06-09 13:00 ` is_predicate_p? Nathan Sidwell
  0 siblings, 2 replies; 19+ messages in thread
From: Robert Dewar @ 2002-06-09 10:15 UTC (permalink / raw)
  To: dnovillo, nathan; +Cc: gcc, jason

<<I personally tend to use is_foo for adjectives (e.g.,
is_binary_expr) and foo_p for verbs (e.g., stmt_ends_bb_p).
>>

But the _p here seems gratuitous, stmt_ends_bb is a perfectly reasonable
name for a predicate and reads just fine.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-09  6:56 ` is_predicate_p? Nathan Sidwell
  2002-06-09  8:07   ` is_predicate_p? Gabriel Dos Reis
@ 2002-06-09 10:09   ` Diego Novillo
  1 sibling, 0 replies; 19+ messages in thread
From: Diego Novillo @ 2002-06-09 10:09 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: Jason Merrill, gcc

On Sun, 09 Jun 2002, Nathan Sidwell wrote:

> I'd vote for the _p convention. FWIW I used to use the is_ convention and
> found it more awkward. I think the reason may be that with predicates
> you are asking a question, and in english you'd use a ? at the end of the
> sentance. The is_foo form looks a little like an assertion. May be a
> spanish speaker would prefer the is_ convention (or even is_foo_p :-)
> 
In spanish we surround questions around two markers: ¿?.  So, if
anything it looks even less like a question to us :)

I personally tend to use is_foo for adjectives (e.g.,
is_binary_expr) and foo_p for verbs (e.g., stmt_ends_bb_p).  

We also have uses of _p for pointers.  If we are going to use a
new convention I would rather get rid of _p entirely.


Diego.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-09  6:56 ` is_predicate_p? Nathan Sidwell
@ 2002-06-09  8:07   ` Gabriel Dos Reis
  2002-06-09 10:09   ` is_predicate_p? Diego Novillo
  1 sibling, 0 replies; 19+ messages in thread
From: Gabriel Dos Reis @ 2002-06-09  8:07 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: Jason Merrill, gcc

Nathan Sidwell <nathan@codesourcery.com> writes:

| Jason Merrill wrote:
| > 
| > Predicates in GCC come in a wide variety of spellings.  Some end in _p,
| > some start with is_, some have _is_ in the middle, some just expect you to
| > know they're predicates based on the meaning of the name.  Should we set
| > some sort of standard spelling for future additions?
| 
| I'd vote for the _p convention. FWIW I used to use the is_ convention and
| found it more awkward. I think the reason may be that with predicates
| you are asking a question, and in english you'd use a ? at the end of the
| sentance. The is_foo form looks a little like an assertion.

However, note that predicates are barely used alone.  There are used
in conditional expressions and the question being asked is part of the
expression:

   if (is_explicit_specialization (decl) && is_type (decl))
      post_process_explicit_type_specialization (decl);

is much more readable to me as a non-native speaker (neither
English, nor LISP), than 

   if (explicit_specialization_p (decl) && type_p (decl))
      post_process_explicit_type_specialization (decl);
    
But, hey:

| May be a
| spanish speaker would prefer the is_ convention (or even is_foo_p :-)

:-) :-)

-- Gaby

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08  1:11 is_predicate_p? Jason Merrill
@ 2002-06-09  6:56 ` Nathan Sidwell
  2002-06-09  8:07   ` is_predicate_p? Gabriel Dos Reis
  2002-06-09 10:09   ` is_predicate_p? Diego Novillo
  0 siblings, 2 replies; 19+ messages in thread
From: Nathan Sidwell @ 2002-06-09  6:56 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc

Jason Merrill wrote:
> 
> Predicates in GCC come in a wide variety of spellings.  Some end in _p,
> some start with is_, some have _is_ in the middle, some just expect you to
> know they're predicates based on the meaning of the name.  Should we set
> some sort of standard spelling for future additions?

I'd vote for the _p convention. FWIW I used to use the is_ convention and
found it more awkward. I think the reason may be that with predicates
you are asking a question, and in english you'd use a ? at the end of the
sentance. The is_foo form looks a little like an assertion. May be a
spanish speaker would prefer the is_ convention (or even is_foo_p :-)

Although I use lisp, I don't consider myself as coming from a lisp
background.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08 19:16   ` is_predicate_p? Tim Hollebeek
@ 2002-06-08 20:16     ` Kaveh R. Ghazi
  0 siblings, 0 replies; 19+ messages in thread
From: Kaveh R. Ghazi @ 2002-06-08 20:16 UTC (permalink / raw)
  To: gdr, tim; +Cc: gcc

 > From: Tim Hollebeek <tim@hollebeek.com>
 > 
 > > | FWIW, I also think we should standardize on all of them returning
 > > | bool. 
 > > 
 > > I think that was agreed upon, in past discussions.
 > 
 > It might also be worthwhile insisting that they be pure.
 > -Tim

Unfortunately, that's almost impossible given our various "checking"
functions make unpure noreturn calls when an error is found.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08  8:36 ` is_predicate_p? Gabriel Dos Reis
@ 2002-06-08 19:16   ` Tim Hollebeek
  2002-06-08 20:16     ` is_predicate_p? Kaveh R. Ghazi
  0 siblings, 1 reply; 19+ messages in thread
From: Tim Hollebeek @ 2002-06-08 19:16 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: Kaveh R. Ghazi, gcc


> | FWIW, I also think we should standardize on all of them returning
> | bool. 
> 
> I think that was agreed upon, in past discussions.

It might also be worthwhile insisting that they be pure.

-Tim

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is predicate p?
  2002-06-08  3:44 ` is_predicate_p? Gabriel Dos Reis
@ 2002-06-08  9:27   ` Marc Espie
  0 siblings, 0 replies; 19+ messages in thread
From: Marc Espie @ 2002-06-08  9:27 UTC (permalink / raw)
  To: gcc

In article <m3ptz26ol5.fsf@merlin.nerim.net> you write:
>kenner@vlsi1.ultra.nyu.edu (Richard Kenner) writes:
>
>|     I would have guidelines rather than a standard here. I would avoid the
>|     use of _p unless you do decide to standardize on this (which seems
>|     very dubious to me). The use of _p is simply not intuitive. 
>| 
>| Perhaps, but it was the earliest conventions used in GCC to distinguish
>| predicates (where the term doesn't have the technical MD file meaning), so
>| most follow this "rule".  This is from LISP conventions and RMS was the
>| origin of its use.

>Writing LISP in C always seems to me to be an intriguing idea 8-\

>-- Gaby


Then why are you writing gcc code ?

gcc is still lisp, mostly.

In fact, I would tend to believe LISP is the only language RMS really knows,
based on his code...

One thing though: gcc would probably be faster if it was truely a dialect
of lisp, like schemes... note that most of the speed trouble we've seen so far
has to do with shared structures, GC, and list processing. (which doesn't
surprise me), and part of the robustness trouble had to do with ubiquitous
structures with actually little or no type at all (e.g., tree nodes, for 
instance). Those are both traditionally plagues of old functional languages...

Food for thought. Or pure jest. You decide.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08  7:45 is_predicate_p? Kaveh R. Ghazi
@ 2002-06-08  8:36 ` Gabriel Dos Reis
  2002-06-08 19:16   ` is_predicate_p? Tim Hollebeek
  0 siblings, 1 reply; 19+ messages in thread
From: Gabriel Dos Reis @ 2002-06-08  8:36 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: gcc

"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:

|  > From: Jason Merrill <jason@redhat.com> 
|  > 
|  > Predicates in GCC come in a wide variety of spellings.  Some end in
|  > _p, some start with is_, some have _is_ in the middle, some just
|  > expect you to know they're predicates based on the meaning of the
|  > name.  Should we set some sort of standard spelling for future
|  > additions?
|  > Jason
| 
| Probably, care to suggest one?

All but the _p thingy seems a bit intriguing to me (although I know
where ot comes from -- I just believe that we shouldn't be insisting
to write LISP in C :-\)

| FWIW, I also think we should standardize on all of them returning
| bool. 

I think that was agreed upon, in past discussions.

-- Gaby

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
@ 2002-06-08  7:45 Kaveh R. Ghazi
  2002-06-08  8:36 ` is_predicate_p? Gabriel Dos Reis
  0 siblings, 1 reply; 19+ messages in thread
From: Kaveh R. Ghazi @ 2002-06-08  7:45 UTC (permalink / raw)
  To: gcc

 > From: Jason Merrill <jason@redhat.com> 
 > 
 > Predicates in GCC come in a wide variety of spellings.  Some end in
 > _p, some start with is_, some have _is_ in the middle, some just
 > expect you to know they're predicates based on the meaning of the
 > name.  Should we set some sort of standard spelling for future
 > additions?
 > Jason

Probably, care to suggest one?

FWIW, I also think we should standardize on all of them returning
bool.  It helps to emphasize the nature/purpose of the function.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
@ 2002-06-08  4:13 Robert Dewar
  0 siblings, 0 replies; 19+ messages in thread
From: Robert Dewar @ 2002-06-08  4:13 UTC (permalink / raw)
  To: dewar, kenner; +Cc: gcc

> Perhaps, but it was the earliest conventions used in GCC to distinguish
> predicates (where the term doesn't have the technical MD file meaning), so
> most follow this "rule".  This is from LISP conventions and RMS was the
> origin of its use.

OK, if this is a well established and well used convention, that's reasonable,
but I still find it odd to use a Hungarian-like convention like this and not
enforce it.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
  2002-06-08  3:42 is_predicate_p? Richard Kenner
@ 2002-06-08  3:44 ` Gabriel Dos Reis
  2002-06-08  9:27   ` is predicate p? Marc Espie
  0 siblings, 1 reply; 19+ messages in thread
From: Gabriel Dos Reis @ 2002-06-08  3:44 UTC (permalink / raw)
  To: Richard Kenner; +Cc: dewar, gcc

kenner@vlsi1.ultra.nyu.edu (Richard Kenner) writes:

|     I would have guidelines rather than a standard here. I would avoid the
|     use of _p unless you do decide to standardize on this (which seems
|     very dubious to me). The use of _p is simply not intuitive. 
| 
| Perhaps, but it was the earliest conventions used in GCC to distinguish
| predicates (where the term doesn't have the technical MD file meaning), so
| most follow this "rule".  This is from LISP conventions and RMS was the
| origin of its use.

Writing LISP in C always seems to me to be an intriguing idea 8-\

-- Gaby

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: is_predicate_p?
@ 2002-06-08  3:42 Richard Kenner
  2002-06-08  3:44 ` is_predicate_p? Gabriel Dos Reis
  0 siblings, 1 reply; 19+ messages in thread
From: Richard Kenner @ 2002-06-08  3:42 UTC (permalink / raw)
  To: dewar; +Cc: gcc

    I would have guidelines rather than a standard here. I would avoid the
    use of _p unless you do decide to standardize on this (which seems
    very dubious to me). The use of _p is simply not intuitive. 

Perhaps, but it was the earliest conventions used in GCC to distinguish
predicates (where the term doesn't have the technical MD file meaning), so
most follow this "rule".  This is from LISP conventions and RMS was the
origin of its use.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* is_predicate_p?
@ 2002-06-08  1:11 Jason Merrill
  2002-06-09  6:56 ` is_predicate_p? Nathan Sidwell
  0 siblings, 1 reply; 19+ messages in thread
From: Jason Merrill @ 2002-06-08  1:11 UTC (permalink / raw)
  To: gcc

Predicates in GCC come in a wide variety of spellings.  Some end in _p,
some start with is_, some have _is_ in the middle, some just expect you to
know they're predicates based on the meaning of the name.  Should we set
some sort of standard spelling for future additions?

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2002-06-09 20:54 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-08  3:20 is_predicate_p? Robert Dewar
2002-06-08  3:48 ` is_predicate_p? Jason Merrill
  -- strict thread matches above, loose matches on Subject: below --
2002-06-09 13:49 is_predicate_p? Robert Dewar
2002-06-09 14:59 ` is_predicate_p? Daniel Jacobowitz
2002-06-09 10:15 is_predicate_p? Robert Dewar
2002-06-09 12:57 ` is_predicate_p? Diego Novillo
2002-06-09 13:00 ` is_predicate_p? Nathan Sidwell
2002-06-08  7:45 is_predicate_p? Kaveh R. Ghazi
2002-06-08  8:36 ` is_predicate_p? Gabriel Dos Reis
2002-06-08 19:16   ` is_predicate_p? Tim Hollebeek
2002-06-08 20:16     ` is_predicate_p? Kaveh R. Ghazi
2002-06-08  4:13 is_predicate_p? Robert Dewar
2002-06-08  3:42 is_predicate_p? Richard Kenner
2002-06-08  3:44 ` is_predicate_p? Gabriel Dos Reis
2002-06-08  9:27   ` is predicate p? Marc Espie
2002-06-08  1:11 is_predicate_p? Jason Merrill
2002-06-09  6:56 ` is_predicate_p? Nathan Sidwell
2002-06-09  8:07   ` is_predicate_p? Gabriel Dos Reis
2002-06-09 10:09   ` is_predicate_p? Diego Novillo

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).