comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Graham <pgraham@cadence.com>
Subject: Re: Language Lawyer question
Date: 2000/06/02
Date: 2000-06-02T00:00:00+00:00	[thread overview]
Message-ID: <39381943.88350E6@cadence.com> (raw)
In-Reply-To: 39380CEB.2CC4682E@ftw.rsc.raytheon.com

Wes Groleau wrote: 
>    Why do we have to write
>       Some_Type'Pred (Some_Value)
>    when
>       Some_Value'Pred
>    is more natural/intuitive and
>    carries just as much type info?
> 
> I pointed out that there is no type info in a literal (like
> Orange'Pred) but he said that the type info would be somewhere
> else in the statement.  I could not quickly come up with a
> counter-example. Plus, how often would we use a literal as
> parameter to 'Pred ?  Might as well just use the literal value 
> of the Predecessor.

It could be Some_Type'Pred(f(x)) for an arbitrary function f (this has
the same problem as your example using a literal, but is more realistic.

Or you might want to say Integer'Pred(1+1), which is easier to parse
than (1+1)'Pred.

An attribute like 'Pred has a kind of qualified expression syntax, if
you think of Pred as an overloaded function predefined on all discrete
types.  Then the type qualifier Some_Type' resolves the overloading.

Paul




  reply	other threads:[~2000-06-02  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-02  0:00 Language Lawyer question Wes Groleau
2000-06-02  0:00 ` Paul Graham [this message]
2000-06-02  0:00 ` David C. Hoos, Sr.
2000-06-02  0:00   ` Keith Thompson
2000-06-04  0:00     ` Robert I. Eachus
2000-06-05  0:00       ` Robert A Duff
2000-06-05  0:00     ` Robert Dewar
2000-06-05  0:00   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox