Sujet : Re: basic BASIC question
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vmsDate : 01. Feb 2025, 05:29:50
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vnk7vu$mka$1@reader2.panix.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
679d7b05$0$713$14726298@news.sunsite.dk>,
Arne Vajhøj <
arne@vajhoej.dk> wrote:
On 1/31/2025 5:05 PM, Dan Cross wrote:
In article <679d26bd$0$713$14726298@news.sunsite.dk>,
Arne Vajhøj <arne@vajhoej.dk> wrote:
But there is no consistency between languages.
>
$ type dump.for
[snip]
I don't know why this should be surprising?
>
I don't know if it is surprising, but it is inconsistent.
What I mean is, why is it notable that they are inconsistent?
They are, after all, different languages that come from
different places and took different evolutionary paths. They
have different standards defining them and mandating different
things; Pascal and C, define the values of the boolean literals
as 0 and 1; C goes further and mandates that the allowable
values in a `bool` are 0 (false) and 1 (true). The reference
manuals for the versions of BASIC and Fortran in use here
mandate that -1 is the value for the `false` literal.
Fortran Pascal C Basic
true literal -1 1 usually 1 usually -1
false literal 0 0 0 0
test low bit set low bit set not 0 not 0
These program snippets conflate two separate things: whether an
integer, when evaluated in a boolean context, yields a `true` or
`false` value, and the value that represents a literal `true`
constant.
4 languages - 4 ways of doing it.
Four different syntaxes, too. :-)
- Dan C.