FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » error message I don understand
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Nasty language semantics [message #174931 is a reply to message #174914] Mon, 18 July 2011 16:17 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
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(at)news(dot)demon(dot)co(dot)uk> (2004)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Ouion Movement, Roun Time (Floating Point Time)
Next Topic: [MEMCACHED] Is there a way to get the expiration of a key?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 01:14:36 GMT 2024

Total time taken to generate the page: 0.04516 seconds