Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2619

Re: Nasty language semantics

Message-ID <8862364.SEqChMirdb@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-07-18 18:17 +0200
Subject Re: Nasty language semantics
Newsgroups comp.lang.php
References (4 earlier) <slrnj263jm.207.hellsop@nibelheim.ninehells.com> <ivv775$egh$1@dont-email.me> <timstreater-EA2F23.20233117072011@news.individual.net> <ivvee0$eqg$1@news.albasani.net> <76idnXX5CP7_3r7TnZ2dnUVZ_rGdnZ2d@posted.localnet>
Followup-To comp.lang.php

Followups directed to: comp.lang.php

Show all headers | View raw


Robert Heller wrote:

> The Natural Philosopher wrote:
>> I want to know that '1.02' + '3.7' is reliably going to be either '4.72'
>> or '1.023.7', not  implementation dependent, as I found in at least one
>> Javascript example.

To the best of my knowledge there is no such non-conforming ECMAScript 
implementation.  You (or the author of the example) must have been doing 
something else wrong.

> Javascript's main problem here is using a common numerical operator (+)
> as a string operator as will AND allowing numbers to promoted (or
> demoted) to strings.  Javascript *could* have picked a different
> operator for string concatenation, something less likely to cause
> ambigious interpretation.

There is no "Javascript"¹.

If you think about this, it would have been rather difficult for the 
designer of JavaScript (and, as a consequence, the ECMAScript committee) to 
choose another operator for concatenation that was widely accepted, given 
that he needed the language to resemble Java (hence the name, changed from 
LiveScript).  They could not use today's PHP's `.', because that was already 
taken for property access by Java (where PHP has the C++-ish `->' instead).  
They could not use `<<' etc, because that was used for SHL/SHR already.  And 
they could not have skipped the implicit type conversion because the 
language needed to be loosely typed (one design goal was a language that was 
flexible, and easy to use, compared to Java).

I wouldn't mind if they chose C++/Python's optional whitespace operator for 
concatenating string literals (that would have made writing/reading long 
strings in source code considerably easier), and PHP's variable expansion 
mechanism or Python's sprintf() mechanism (`%') for dealing with 
"concatenation" of non-string values (IIRC, efforts for built-in string 
templates in JavaScript 2.0 are underway).  (`%' would have been ambiguous, 
though, and might have meant a unwanted diversion from Java by introduction 
of a `mod' operator instead.)


PointedEars
___________
¹ <http://PointedEars.de/es-matrix>
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
 -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-15 14:38 +0000
  Re: error message I don understand Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-15 10:44 -0400
    Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-15 17:26 +0000
      Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-15 18:45 +0100
        Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-15 18:36 +0000
          Re: error message I don understand VanguardLH <V@nguard.LH> - 2011-07-15 14:25 -0500
            Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-15 21:36 +0100
              Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-16 09:17 +0000
                Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-16 13:52 +0100
              Re: error message I don understand Heinrich Käsner <heinkasner@gmail.com> - 2011-08-02 07:02 -0700
          Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-15 21:35 +0100
          Re: error message I don understand Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-16 09:30 -0400
            Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-16 19:14 +0000
              Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-16 22:18 +0100
  Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-15 17:49 +0100
    Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-15 17:25 +0000
  Re: error message I don understand Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-07-16 19:28 +0000
    Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-17 08:21 +0000
      Re: error message I don understand Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-17 11:10 +0200
        Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-17 10:20 +0100
          Re: error message I don understand Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 09:01 -0400
        Re: error message I don understand Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 09:00 -0400
          Re: error message I don understand Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-07-17 14:53 +0000
            Re: error message I don understand dougatmilmacdotcom@example.com (Doug Miller) - 2011-07-17 16:26 +0000
            Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-18 16:11 +0000
        Re: error message I don understand Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-07-17 14:52 +0000
          Re: error message I don understand Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-18 17:19 +0200
            Re: error message I don understand The Natural Philosopher <tnp@invalid.invalid> - 2011-07-18 17:01 +0100
        Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-18 16:07 +0000
          Re: error message I don understand Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-18 18:27 +0200
            Re: error message I don understand "liebling.kreuzberg@gmail.com" <liebling.kreuzberg@gmail.com> - 2011-07-18 20:12 +0000
  Re: error message I don understand August Karlstrom <fusionfile@gmail.com> - 2011-07-17 14:55 +0200
    Re: error message I don understand Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 09:03 -0400
      Re: error message I don understand August Karlstrom <fusionfile@gmail.com> - 2011-07-17 16:50 +0200
        Re: error message I don understand Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 12:26 -0400
        Re: error message I don understand "Peter H. Coffin" <hellsop@ninehells.com> - 2011-07-17 11:31 -0500
          Nasty language semantics (Was: error message I don understand) August Karlstrom <fusionfile@gmail.com> - 2011-07-17 19:47 +0200
            Re: Nasty language semantics (Was: error message I don understand) Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 14:12 -0400
            Re: Nasty language semantics (Was: error message I don understand) Robert Heller <heller@deepsoft.com> - 2011-07-17 13:26 -0500
            Re: Nasty language semantics (Was: error message I don understand) Tim Streater <timstreater@greenbee.net> - 2011-07-17 20:23 +0100
              Re: Nasty language semantics (Was: error message I don understand) The Natural Philosopher <tnp@invalid.invalid> - 2011-07-17 20:50 +0100
                Re: Nasty language semantics (Was: error message I don understand) Robert Heller <heller@deepsoft.com> - 2011-07-17 15:17 -0500
                Re: Nasty language semantics (Was: error message I don understand) The Natural Philosopher <tnp@invalid.invalid> - 2011-07-17 21:21 +0100
                Re: Nasty language semantics Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-18 18:17 +0200
                Re: Nasty language semantics (Was: error message I don understand) Tim Streater <timstreater@greenbee.net> - 2011-07-17 23:06 +0100
                Re: Nasty language semantics (Was: error message I don understand) August Karlstrom <fusionfile@gmail.com> - 2011-07-18 00:48 +0200
                Re: Nasty language semantics (Was: error message I don understand) Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 19:23 -0400
                Re: Nasty language semantics (Was: error message I don understand) August Karlstrom <fusionfile@gmail.com> - 2011-07-18 01:51 +0200
                Re: Nasty language semantics (Was: error message I don understand) Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-17 21:18 -0400
                Re: Nasty language semantics (Was: error message I don understand) Tim Streater <timstreater@greenbee.net> - 2011-07-18 09:22 +0100
                Re: Nasty language semantics (Was: error message I don understand) "Peter H. Coffin" <hellsop@ninehells.com> - 2011-07-18 10:57 -0500
        Re: error message I don understand Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-18 17:55 +0200
          Nasty language semantics (Was: error message I don understand) August Karlstrom <fusionfile@gmail.com> - 2011-07-18 20:31 +0200
            Re: Nasty language semantics Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-18 21:29 +0200

csiph-web