Sujet : Re: Simple Pascal question
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vmsDate : 04. Aug 2024, 13:22:01
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <v8nrp9$3tp$1@reader1.panix.com>
References : 1 2 3
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
v8lpj0$ems$1@panix2.panix.com>,
Scott Dorsey <
kludge@panix.com> wrote:
In article <v8hn3m$3aviu$1@gwaiyur.mb-net.net>,
Uli Bellgardt <UliBellgardtsSpamSink@online.de> wrote:
The value 1.5 should be an f_float value as well:
>
$ type zzz.pas
program z(input,output);
>
var
x : f_float;
>
This seems very strange to me... Pascal isn't supposed to have such
strong typing, is it? I don't remember ever having to manually coerce
anything. Or is f_float sufficiently different from a normal float?
Just to touch on the Pascal point itself, one of that language's
hallmarks is almost excessive rigidity in how it treats types.
While integer->float conversions are implicit, the opposite is
not. I think that the general rule is that when a type "widens"
conversion is implicitly ok (so in mathematics, when the
integers are a proper subset of the reals, so every integer is
already a real, and implicit conversion from int to real is
intuitive, even though representations on physical computers
aren't quite so neat for implementation reasons), but when types
narrow, as in when going from real to int, one must exercise
more caution.
An old annoyance about Pascal was that the size of an array is
part of it's type, which makes writing functions and procedures
that work across differently sized arrays challenging.
Interesting, this has become du jour again in modern languages,
but those tend to provide access to a `slice` type that provides
a window onto the underly array, and implicitly encodes a
length (and usually a "capacity"). This makes working with
arrays in such languages very convenient.
- Dan C.