Giter Site home page Giter Site logo

Comments (4)

vtereshkov avatar vtereshkov commented on May 12, 2024

@marekmaskarinec I think this is a direct consequence of the conventional scope rules. The variable i in somefunc is local, while in main it is global. Does Go behave differently?

from umka-lang.

marekmaskarinec avatar marekmaskarinec commented on May 12, 2024

To my suprise, go behaves the same, although I think it shouldn't. Redeclaration of a variable like this:

i := 3
i := 2

causes an error like this: no new variables on left side of := (in go).

The case shown earlier is a redeclaration of a variable too. On the other hand, I can see some use cases to a global variable not being forced. It think, this is a good case for a warning.

from umka-lang.

vtereshkov avatar vtereshkov commented on May 12, 2024

Some languages like V disallow shadowing global variables with local ones, though most historically important languages, including C, allow this without a warning.

Moreover, warnings in interpreted languages are very rarely used, since they would be displayed again and again each time the user runs the program. It should be either an error or nothing.

from umka-lang.

marekmaskarinec avatar marekmaskarinec commented on May 12, 2024

Ok. I can see some reasons, you would want to overwrite a global variable. I was just confused.

from umka-lang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.