Comments (7)
- 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.
- 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.
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.
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.
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.
I've added the most urgent thing right now (#77), when I have some more time I will add the rest.
from luna.
👍
from luna.
Related Issues (20)
- Application make warning: implicit declaration of function 'strdup' is invalid in C99 [-Wimplicit-function-declaration] HOT 5
- Program received signal SIGSEGV, Segmentation fault HOT 2
- Program received signal SIGSEGV, Segmentation fault in primary_expr
- Program received signal SIGSEGV, Segmentation fault:in visit_call
- Parse declaration
- Store source position in AST nodes
- Compilation errors ... HOT 1
- Overloaded project name? HOT 3
- Performance? HOT 4
- Dot syntax sugar and modules.
- Framework for Luna HOT 7
- Question: Add more specfic list of features and goals that you want to have HOT 1
- Request for clarification/documentation HOT 3
- Type systems
- Is there a reason of the overuse of macros in the source code? HOT 1
- Register machine
- Choose a different language name? HOT 3
- Application crash when debug parser
- Missing image on installer HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luna.