Comments (1)
The compiler already refuses to initialize or assign variables later used in loop
, reporting that they are read-only. So I was wrong when I said "x is mine".
var int x = 7; // invalid assignment : read-only variable "x"
loop x in [2->8] do ... end
Hence what's left of this issue is:
- Bug: The compiler should detect and prevent the nested loop example.
- Enhancement: Make the loop variable unreadable after loop exit, to avoid undefined behaviour and thus non-determinism. (Alternatively try really hard to precisely define the value. Not trivial with C as a backend, where lots of simple operations cause undefined behaviour, e.g. signed addition overflow.)
- Enhancement: Syntax
loop var int x in ...
which would avoid all these pitfalls.
Meanwhile, one can take advantage of the current behaviour to provide immutable variables to Céu:
#define constvar(typ,name,value) \
var typ name; \
loop/1 name in [ (value) -> _] do break; end
constvar(uint, x, 1+2*3);
_printf("%u\n",x);
//x = 7; // invalid assignment : read-only variable "x"
Alas, vec[x] is still not the same as vec[7] (dynamic vs. static allocation). That would require real support for constants in Céu.
from ceu.
Related Issues (20)
- Add support for `while` loop
- Bug in Compiler
- Accept `until` for `code/await`
- http://fsantanna.github.io/* should be http://ceu-lang.github.io/* HOT 1
- Bad message for error regarding prototype declaration and code/call HOT 1
- Error with code/dynamic using multiple trails
- "Invalid binding : incompatible scopes" error not being detected inside watching statement
- Unexpected error with dynamic spawn before subtype declaration
- Instructions in INSTALL.md seem outdated
- Example 15 from "Try Ceu" page isn't correct HOT 3
- invalid input pool[7] uint ids; crashes the compiler HOT 1
- Correct #line numbers HOT 1
- Integrate run-time assertions with Céu Exceptions HOT 1
- Use "kill" command makes application terminates unexpectedly HOT 2
- await for a code/await abstraction inside every does not produce errors HOT 1
- Wrong error message on call method without 'call'. HOT 1
- C comments don't ignore interpolated Céu expressions
- Events declared as a public fields don't work when using code/await prototype
- gcc -O1 and async/thread
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 ceu.