Code Monkey home page Code Monkey logo

Comments (7)

aisk avatar aisk commented on June 16, 2024
  • I think immutable brings more complex like:
    • Wether the value is immutable or just the pointer to the value (exactly the value' RAM address) is immutable, or both?
    • If the value is immutable, the container and string types's performence will be more slow. But we can optimise them like Haskell and immutable.js dose.
  • It's better to have no uninitialised value, like Golang dose. for example, if we defined a uninitialised variable, the value is already malloced on the heap (or just on the stack), and the value should be a instinct zero value, like 0 for a number, "" for a string, "[]" for a list.
  • I like function scope because we can write if condition { let a = 1} else { let a =2 }; print(a).

from luna.

glhrmfrts avatar glhrmfrts commented on June 16, 2024
  • If we bring immutability, it would be good to let the variables mutate but not the data structures, @tj even mentioned this at #45, besides we can optimise like you said. The opposite doesn't make much sense and if both were immutable Luna would turn into a pure-functional language, which I think it's not it's target.
  • That's true, but then the user would have to obligatory declare the type of the variable before the assignment, I find that very strict but it might be less error-prone than having a nil value.
  • Yeah, function scope fits better with Luna style, another option is to let loops have their own scope but not the if statement.

from luna.

aisk avatar aisk commented on June 16, 2024

Put it together:

if some_condition:
  let a = "foo"
else
  let a = 42
end

# what's the type of a? If we have a static linter, it's hard to lint the rest of code with operations to a.

So I think people will not write codes like this, declare the type of variable before assign value to it is acceptable in my opinion. And function scope is a bad choice I thought now (I think most static typed languages have block scope as I can remember).

And certainly the variables must be mutable above. Or we should write codes like this:

let a = if some_condition
  return "foo"
else
  return "bar"
end

This will hard to write code if we have a complex condition and multiple variable to assign, so I agree with you (mutable variable and immutable value like clojure dose).

from luna.

glhrmfrts avatar glhrmfrts commented on June 16, 2024

I understand you now, it wouldn't be possible to analyze the program statically with uninitialized variables without a type or function scope.

So we have:

  • Mutable variables
  • Immutable values
  • Block scope

I think that's pretty good. I will leave this open for now though, we got a lot of work haha.

from luna.

aisk avatar aisk commented on June 16, 2024

Hi can you open some issues about what to do, so people can join this repo quickly, thank you 😊

I saw the issues about what to do, some were to generic ...

from luna.

glhrmfrts avatar glhrmfrts commented on June 16, 2024

I've added the most urgent thing right now (#77), when I have some more time I will add the rest.

from luna.

aisk avatar aisk commented on June 16, 2024

👍

from luna.

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.