Hacker News new | ask | show | jobs
by djmetzle 1685 days ago
Oh no. oh no no. Do you have examples of languages without the usual local scope binding semantics?

I think the example here is misleading and causing confusion.

2 comments

I believe Wolfram Mathematica has this terrible global scoping by default.

It's not exactly a language that programmers refer to often, as it's not really general purpose, but I had to do some work with MRI data in it and I hated it mostly due to the scoping.

An "I spent a decent bit of time rewriting the entire lab's codebase in python" type of hate.

Javascript and C.

Neither are considered pinnacles of language design.

Javascript requires explicit variable declaration if you're bringing it to a new scope, though. Which is to say:

    var s = "Geeksforgeeks";
    function f_global() {
        s = "Me too";
    }
    // is different from
    function f_local() {
        var s = "Me too";
    }
I like that better (and I realize I might be alone!). But I don't like that you can declare a global variable in a local function by omitting the var. It's a similar needless ambiguity and frankly much more prone to errors than the python local variable initialization. At least there is strict mode.