Re: basic BASIC question

Liste des GroupesRevenir à co vms 
Sujet : Re: basic BASIC question
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vms
Date : 07. Feb 2025, 04:15:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vo3ts7$379us$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 2/6/2025 4:20 PM, Lawrence D'Oliveiro wrote:
On Thu, 6 Feb 2025 11:04:12 -0500, Arne Vajhøj wrote:
If JavaScript was unique in the web frontend world for lack of type
safety, then the lack of type safety could be due to its history.
Other popular languages like PHP and Python also has a relaxed
approach to types.
 Worth being clear what we’re talking about. None of these languages is
type-unsafe in the way that C, for example, allows free typecasting
between unrelated types, and in particular between pointers to unrelated
types. They are all dynamic languages, and every value that a variable can
hold does have an explicit type, and conversions between types follow
well-founded semantic rules.
 However, JavaScript and PHP have a laissez-faire attitude to equivalences
with strings, and will happily autoconvert between strings and non-string
types in various situations, often leading to surprising results. This is
why both those languages have the “===” comparison operator as a stricter
form of “==” which says “turn off these string-nonstring autoconversions”.
 Python never had this particular bit of brain damage. But it does still
have that common weakness with booleans. Which is a more manageable issue.
There are different conventions.
$ type cmp.php
<?php
function test($a, $b) {
     if($a == $b) {
         echo "true ";
     } else {
         echo "false ";
     }
     if($a === $b) {
         echo "true\r\n";
     } else {
         echo "false\r\n";
     }
}
test(0, 0);
test(0, 0.0);
test(0, '0');
test(0, 'X');
test(0, False);
test(0, null);
?>
$ php cmp.php
true true
true false
true false
false false
true false
true false
$ type cmp.py
def test(a, b):
     if a == b:
         print('true')
     else:
         print('false')
test(0, 0)
test(0, 0.0)
test(0, '0')
test(0, 'X')
test(0, False)
test(0, None)
$ python cmp.py
true
true
false
false
true
false
$ type Cmp.groovy
def test(a, b) {
     if(a == b) {
         println("true")
     } else {
         println("false")
     }
}
test(0, 0)
test(0, 0.0)
test(0, "0")
test(0, "X")
test(0, false)
test(0, null)
$ groovy Cmp.groovy
true
true
false
false
false
false
$ type Cmp.java
public class Cmp {
     private static void test(Object a, Object b) {
         if(a.equals(b)) {
             System.out.println("true");
         } else {
             System.out.println("false");
         }
     }
     public static void main(String[] args) {
         test(0, 0);
         test(0, 0.0);
         test(0, "0");
         test(0, "X");
         test(0, false);
         test(0, null);
     }
}
$ javac Cmp.java
$ java Cmp
true
false
false
false
false
false
Arne

Date Sujet#  Auteur
31 Jan 25 * basic BASIC question62Arne Vajhøj
31 Jan 25 +* Re: basic BASIC question3Robert A. Brooks
31 Jan 25 i`* Re: basic BASIC question2Arne Vajhøj
31 Jan 25 i `- Re: basic BASIC question1Chris Townley
31 Jan 25 +- Re: basic BASIC question1jeffrey_dsi
31 Jan 25 +* Re: basic BASIC question35Dave Froble
31 Jan 25 i+* Re: basic BASIC question33Arne Vajhøj
31 Jan 25 ii+* Re: basic BASIC question30Dan Cross
31 Jan 25 iii+* Re: basic BASIC question27Arne Vajhøj
31 Jan 25 iiii+* Re: basic BASIC question11Dan Cross
1 Feb 25 iiiii+* Re: basic BASIC question2Craig A. Berry
1 Feb 25 iiiiii`- Re: basic BASIC question1Arne Vajhøj
1 Feb 25 iiiii`* Re: basic BASIC question8Arne Vajhøj
1 Feb 25 iiiii +* Re: basic BASIC question6Arne Vajhøj
1 Feb 25 iiiii i`* Re: basic BASIC question5Arne Vajhøj
1 Feb 25 iiiii i +- Re: basic BASIC question1Dan Cross
2 Feb 25 iiiii i `* Re: basic BASIC question3Craig A. Berry
2 Feb 25 iiiii i  `* Re: basic BASIC question2Arne Vajhøj
2 Feb 25 iiiii i   `- Re: basic BASIC question1Dan Cross
1 Feb 25 iiiii `- Re: basic BASIC question1Dan Cross
31 Jan 25 iiii`* Re: basic BASIC question15Arne Vajhøj
2 Feb 25 iiii +- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 iiii `* Re: basic BASIC question13Simon Clubley
3 Feb 25 iiii  `* Re: basic BASIC question12Arne Vajhøj
3 Feb 25 iiii   +* Re: basic BASIC question10Lawrence D'Oliveiro
4 Feb 25 iiii   i`* Re: basic BASIC question9Arne Vajhøj
4 Feb 25 iiii   i +* Re: basic BASIC question7Lawrence D'Oliveiro
4 Feb 25 iiii   i i`* Re: basic BASIC question6Arne Vajhøj
4 Feb 25 iiii   i i +* Re: basic BASIC question2Lawrence D'Oliveiro
5 Feb 25 iiii   i i i`- Re: basic BASIC question1Arne Vajhøj
5 Feb 25 iiii   i i `* Re: basic BASIC question3Lawrence D'Oliveiro
5 Feb 25 iiii   i i  `* Re: basic BASIC question2Arne Vajhøj
5 Feb 25 iiii   i i   `- Re: basic BASIC question1Lawrence D'Oliveiro
4 Feb 25 iiii   i `- Re: basic BASIC question1Dan Cross
5 Feb 25 iiii   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 iii`* Re: basic BASIC question2Chris Townley
31 Jan 25 iii `- Re: basic BASIC question1Dan Cross
1 Feb 25 ii`* Re: basic BASIC question2Dave Froble
1 Feb 25 ii `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 i`- Re: basic BASIC question1Chris Townley
31 Jan 25 +* Re: basic BASIC question20Simon Clubley
31 Jan 25 i+* Re: basic BASIC question17Arne Vajhøj
31 Jan 25 ii`* Re: basic BASIC question16Arne Vajhøj
31 Jan 25 ii +* Re: basic BASIC question14Dan Cross
3 Feb 25 ii i`* Re: basic BASIC question13Simon Clubley
3 Feb 25 ii i +* Re: basic BASIC question2John Dallman
3 Feb 25 ii i i`- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 ii i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i `* Re: basic BASIC question9Arne Vajhøj
6 Feb 25 ii i  +- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  +* Re: basic BASIC question5Dan Cross
6 Feb 25 ii i  i`* Re: basic BASIC question4Arne Vajhøj
6 Feb 25 ii i  i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i  i `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i  i  `- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 ii `- Re: basic BASIC question1Lawrence D'Oliveiro
1 Feb 25 i`* Re: basic BASIC question2Dave Froble
3 Feb 25 i `- Re: basic BASIC question1Simon Clubley
2 Feb 25 +- Re: basic BASIC question1Lawrence D'Oliveiro
2 Apr 25 `- Re: basic BASIC question1Johnny Billquist

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal