Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: "When closures capture their context" and "scope gotchas in Javascript"

by moritz (Cardinal)
on Feb 08, 2008 at 16:57 UTC ( #667017=note: print w/ replies, xml ) Need Help??


in reply to Re: "When closures capture their context" and "scope gotchas in Javascript"
in thread "When closures capture their context" and "scope gotchas in Javascript"

Speaking of other language woes - I intended to learn Lua, until I found out that variables are global by default, and you have to add a keyword to limit their scope to the current sub/method.

That, and the fact that I couldn't find a use strict; equivalent made me jump back to perl immediately.


Comment on Re^2: "When closures capture their context" and "scope gotchas in Javascript"
Download Code
Re^3: "When closures capture their context" and "scope gotchas in Javascript"
by Errto (Vicar) on Feb 08, 2008 at 18:49 UTC
    I intended to learn Lua, until I found out that variables are global by default, and you have to add a keyword to limit their scope to the current sub/method.
    That's true in Perl too if you don't use strict. Well, so in Perl the alternative is lexical scope which, as I know from certain other *ahem*VB*ahem* experience, is much better than subroutine scope for most purposes.
Re^3: "When closures capture their context" and "scope gotchas in Javascript"
by dragonchild (Archbishop) on Feb 09, 2008 at 02:12 UTC
    Which happens to be the reason both tye and I have relegated Ruby to the "Neat Toy" category. If the compiler can't be enlisted to help you catch typos, then your language design is seriously flawed. (That and how does a language by a Japanese hacker go through 3 versions before an American adds support for UTF-8??)

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      how does a language by a Japanese hacker go through 3 versions before an American adds support for UTF-8?
      IIRC Unicode isn't nearly as popular in Asia as it is in, for instance, western Europe.

      Last I heard (some years ago) the Chinese really didn't like it since they already use some kind of encoding that differentiates certain "characters" that look /exactly/ the same but are pronounced differently (which is useful for speech generation), and at least back then the unicode standard did not distinguish between them.

        s/support for Unicode/support for character semantics/g. You cannot have Unicode support without support for character semantics. I only mentioned Unicode because that's been babbled about for Ruby2 for ages.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

        Getting a bit OT here, but what the heck.

        The Unicode standard has always guaranteed a 1:1 two-way mapping with existing character sets, and it contains a number of duplicate characters (in special compatibility regions) to cope with precisely the problem you mention.

        No, the perceived problem with Unicode, when it was first introduced, was that certain characters are traditionally written slightly differently in China and in Japan, and Unicode unified each set of equivalent characters to have a single codepoint. IIRC the Japanese mistakenly assumed that this meant Unicode was trying to force them to use Chinese character shapes, which would obviously have signalled the end of the world.

        Once an anti-Unicode movement had come into existence, they subsequently came up with various other kinds of anti-Unicode FUD; for example, one popular criticism is that Unicode does not necessarily include certain incredibly rare characters used only for writing ancient personal names (not that these were included in the then-standard JIS encodings either), while another, slightly more valid complaint was that UTF-8 required three bytes for every Japanese character rather than two bytes in Shift_JIS (of course, UTF-16 solves that).

        Anyway, the upshot of all this was that many came to believe that Unicode was inherently unsuitable for encoding Japanese text, hence Ruby's failure to support it initially. Thankfully the resistance seems to be dying, perhaps aided by the fact that the Japanese language still exists even though Windows has been using Unicode internally for many years now...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://667017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-08-28 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls