comp.lang.ada
 help / color / mirror / Atom feed
* Re: Compiler Warnings (Was: Suprise of comparison result)
       [not found]     ` <37FFED44.6E756E81@callnetuk.com>
@ 1999-10-11  0:00       ` Nick Roberts
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Roberts @ 1999-10-11  0:00 UTC (permalink / raw)


> In the warning text, T is replaced by the expanded name of type T.

Corrigendum:

In the warning text, R is replaced by the image of the value R.

-- 
Nick Roberts
Computer Consultant (UK)
http://www.callnetuk.com/home/nickroberts
http://www.adapower.com/lab/adaos






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

* Re: Suprise of comparison result
       [not found] <37fd7e17.0@news.pacifier.com>
@ 1999-10-18  0:00 ` Robert Dewar
       [not found] ` <37FDB8D1.CC4CDB7B@gecm.com>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-10-18  0:00 UTC (permalink / raw)


In article <37fd7e17.0@news.pacifier.com>,
  "Steve Doiel" <nospam_steved@pacifier.com> wrote:
> I'm suprised that Ada behaves this way.  Both ObjectAda and
> GNAT give the same result.

That's because it is the well defined result of what was
written. You can always be surprised when you use a construct
you do not understand, in this case the problem is not knowing
the meaning of unary minus on modular types.

> If I were programming in C I would not be suprised at this
> result.  But in Ada?

Well I guess that's because you understand in C the nature
of unsigned modular types. Well the semantics of modular types
are pretty much identical in C and Ada, so the behavior will
indeed be similar!


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Suprise of comparison result
       [not found]   ` <7tke70$lf4$1@ash.prod.itd.earthlink.net>
@ 1999-10-18  0:00     ` Robert Dewar
  1999-10-18  0:00       ` Ted Dennison
  1999-10-19  0:00       ` Robert A Duff
  0 siblings, 2 replies; 8+ messages in thread
From: Robert Dewar @ 1999-10-18  0:00 UTC (permalink / raw)


In article <7tke70$lf4$1@ash.prod.itd.earthlink.net>,
  "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote:
> I believe what happens is that the literals -32768 and 32767
                                              ^^^^^^

This is not a literal, very few languages have negative
literals (APL is an exception). Understanding this is
important in nearly all languages.

To test your understanding, what is the result of

-5 mod 3

Most people get this wrong!


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Suprise of comparison result
       [not found]   ` <37fece61.0@news.pacifier.com>
       [not found]     ` <37FFED44.6E756E81@callnetuk.com>
@ 1999-10-18  0:00     ` Robert Dewar
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-10-18  0:00 UTC (permalink / raw)


In article <37fece61.0@news.pacifier.com>,
  "Steve Doiel" <nospam_steved@pacifier.com> wrote:
> The behavior I had hoped for was a compile time error when I
attempted to
> compare an integer value (-32768) to a modular value.  I
understand that
> things just don't work that way, but it was a bit of a
dissapointment.


But what possible basis would there be for an error here.
It is very useful to have unary minus work on modular
numbers, and it would indeed be a nasty irregularity
if -x was not the same as 0-x for modular types.

If you properly understand twos complement arithmetic,
the use of unary minus is often convenient, for example
doing

   x := -1;

to set x to all 1 bits is often convenient ...


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Suprise of comparison result
       [not found] ` <wccr9j5nat8.fsf@world.std.com>
@ 1999-10-18  0:00   ` Robert Dewar
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-10-18  0:00 UTC (permalink / raw)


In article <wccr9j5nat8.fsf@world.std.com>,
  Robert A Duff <bobduff@world.std.com> wrote:
> Ada's modular types really are at the C level.  Don't use them
> if you don't want to program at that level.

I disagree, they have a well defined abstract semantics that
is nothing to do with level. If you understand these semantics
there is no reason to avoid them, and this has nothing to do
with being at the C "level".


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Suprise of comparison result
  1999-10-18  0:00     ` Robert Dewar
@ 1999-10-18  0:00       ` Ted Dennison
  1999-10-19  0:00       ` Robert A Duff
  1 sibling, 0 replies; 8+ messages in thread
From: Ted Dennison @ 1999-10-18  0:00 UTC (permalink / raw)


In article <7udvrl$npq$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-deja.com> wrote:
> In article <7tke70$lf4$1@ash.prod.itd.earthlink.net>,
>   "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote:
> > I believe what happens is that the literals -32768 and 32767
>                                               ^^^^^^
>
> This is not a literal, very few languages have negative
> literals (APL is an exception). Understanding this is
> important in nearly all languages.

That bit me quite badly recently in OpenToken too. Recognition of
negative literals had to be removed to support programming languages,
but that broke existing code for simpler languages. We eventually had to
add support for negative literals as an option. The header comments may
be enlightening:

  -- One would probably want to disallow signs in languages that use '-'
or
  -- '+' as an operator between integers. If your syntax does not have
such a
  -- concept, you will probably want to allow them.





--
T.E.D.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Suprise of comparison result
  1999-10-18  0:00     ` Robert Dewar
  1999-10-18  0:00       ` Ted Dennison
@ 1999-10-19  0:00       ` Robert A Duff
  1999-10-21  0:00         ` Robert Dewar
  1 sibling, 1 reply; 8+ messages in thread
From: Robert A Duff @ 1999-10-19  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-deja.com> writes:

> To test your understanding, what is the result of
> 
> -5 mod 3
> 
> Most people get this wrong!

Which indicates that (this part of) the language is poorly designed.
But it could be fixed by changing the precedences -- you wouldn't have to
make "-5" be a literal.

It seems to me that unary operators should never be lower precedence
than binary operators.  Do you agree with this language design
principle?

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

* Re: Suprise of comparison result
  1999-10-19  0:00       ` Robert A Duff
@ 1999-10-21  0:00         ` Robert Dewar
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-10-21  0:00 UTC (permalink / raw)


In article <wccyaczqrb3.fsf@world.std.com>,
  Robert A Duff <bobduff@world.std.com> wrote:
> Robert Dewar <robert_dewar@my-deja.com> writes:
>
> > To test your understanding, what is the result of
> >
> > -5 mod 3
> >
> > Most people get this wrong!
>
> Which indicates that (this part of) the language is poorly
designed.
> But it could be fixed by changing the precedences -- you
wouldn't have to
> make "-5" be a literal.
>
> It seems to me that unary operators should never be lower
precedence
> than binary operators.  Do you agree with this language design
> principle?


I am not sure, would you really want to apply this principle
to APL?


Sent via Deja.com http://www.deja.com/
Before you buy.




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

end of thread, other threads:[~1999-10-21  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <37fd7e17.0@news.pacifier.com>
1999-10-18  0:00 ` Suprise of comparison result Robert Dewar
     [not found] ` <37FDB8D1.CC4CDB7B@gecm.com>
     [not found]   ` <37fece61.0@news.pacifier.com>
     [not found]     ` <37FFED44.6E756E81@callnetuk.com>
1999-10-11  0:00       ` Compiler Warnings (Was: Suprise of comparison result) Nick Roberts
1999-10-18  0:00     ` Suprise of comparison result Robert Dewar
     [not found] ` <wccr9j5nat8.fsf@world.std.com>
1999-10-18  0:00   ` Robert Dewar
     [not found] ` <7tk5d5$2qu$1@nnrp1.deja.com>
     [not found]   ` <7tke70$lf4$1@ash.prod.itd.earthlink.net>
1999-10-18  0:00     ` Robert Dewar
1999-10-18  0:00       ` Ted Dennison
1999-10-19  0:00       ` Robert A Duff
1999-10-21  0:00         ` Robert Dewar

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