* 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
1999-10-18 0:00 ` Suprise of comparison result 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 ` Suprise of comparison result 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
[parent not found: <wccr9j5nat8.fsf@world.std.com>]
* Re: Suprise of comparison result
[not found] <37fd7e17.0@news.pacifier.com>
[not found] ` <7tk5d5$2qu$1@nnrp1.deja.com>
[not found] ` <wccr9j5nat8.fsf@world.std.com>
@ 1999-10-18 0:00 ` Robert Dewar
[not found] ` <37FDB8D1.CC4CDB7B@gecm.com>
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
[parent not found: <37FDB8D1.CC4CDB7B@gecm.com>]
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>
[not found] ` <7tk5d5$2qu$1@nnrp1.deja.com>
[not found] ` <7tke70$lf4$1@ash.prod.itd.earthlink.net>
1999-10-18 0:00 ` Suprise of comparison result Robert Dewar
1999-10-18 0:00 ` Ted Dennison
1999-10-19 0:00 ` Robert A Duff
1999-10-21 0:00 ` Robert Dewar
[not found] ` <wccr9j5nat8.fsf@world.std.com>
1999-10-18 0:00 ` Robert Dewar
1999-10-18 0:00 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox