Article View: comp.sys.mac
Article #19024Re: LightSpeed Pascal Problem
From: florman
Date: Fri, 11 Sep 1987 22:40
Date: Fri, 11 Sep 1987 22:40
64 lines
2910 bytes
2910 bytes
>
> I'm working on porting a Turbo Pascal Unit to LightSpeed Pascal, and I've
> hit a catch. In the Turbo Unit, the high bit of an integer is set with
>
> foo := $8000 ; {set high bit -- value is -32768}
>
> But, LightSpeed won't accept that -- it complains that the
> "constant (whose value is -32768) is out of range".
>
> I thought that the range of ints was supposed to be -32768 to +32767.
> I've tried the obvious "hacks", with no luck. For instance:
>
> i := -32767 ;
> i := i-1 ; {nope -- int overflow}
> or
> i := -16384 ;
> i := 2 * i ; {ditto}
>
> I don't know why (yet) but the Unit does not work properly if "foo" does not
> have the high bit set.
>
> I'm using LSP 1.0. Can anyone please help me? Will a more recent version
> of LSP help?
>
> Karl
>
> --
> Karl Klashinsky "Gee, I wish I could find a
> University of Victoria neat quote to put in my
> British Columbia, Canada .signature"
> <me>
> e-mail: {uw-beaver, ubc-vision}!uvicctr!klash
I too have run into this problem more than once. It stems from
Lightspeed's definition of the INTEGER type being -MaxInt..MaxInt, where
MaxInt = 32767. This is documented on page 19 of the reference manual,
and is actually in conformance with the ANSI Standard Pascal, where the
other major Pascals for the Mac are not. So Think probably considers
this to be a "feature" rather than a bug. The solution is to turn off
overflow checking for the offending statements with the $V compiler
directive.
{$V-}
foo := $8000 ; {set high bit -- value is -32768}
{$V+}
It is interesting to note that the documentation for the $V option, on
page 13-3 of the manual, erroneously states the range of INTEGER to be
-32768 to +32767. This is the range for MPW, TML and Turbo, but not
for Lightspeed.
PS. Think has recently posted an update (version 1.1A or something) to
a number of networks. I haven't seen it yet, but it may fix this
problem.
--
========================================================================
florman@rand-unix.ARPA
{decvax,sdcrdcf,trwrb,trwspf,vortex}!rand-unix!gnu!florman
"There is no limit to the amount of good that people can accomplish,
if they don't care who gets the credit."
- Anonymous
Technical Details
Message-ID:
<1122@randvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!hplabs!sdcrdcf!randvax!flormanReferences:
<320@uvicctr.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!hplabs!sdcrdcf!randvax!florman From: florman@randvax.UUCP Newsgroups: comp.sys.mac Subject: Re: LightSpeed Pascal Problem Message-ID: <1122@randvax.UUCP> Date: Fri, 11-Sep-87 18:40:33 EDT Article-I.D.: randvax.1122 Posted: Fri Sep 11 18:40:33 1987 Date-Received: Sun, 13-Sep-87 08:20:05 EDT References: <320@uvicctr.UUCP> Organization: Rand Corp., Santa Monica Lines: 64