Comments (10)
Hi. For declaring a variable with an array type I used "&[i32]" rather than "[i32]". Hope this helps.
from impala.
@FanyuYe Where? In the struct definition? That leads to lvalue required for unary '&' operand
from impala.
This is because you try to assign value to it. So you have to declare it use 'mut' key word.
E.g.
let mut cache_sizes = ...;
from impala.
- You can either use an definite array (of size 3):
struct CS {
sizes : [i32 * 3],
count : i32,
}
let cache_sizes = CS {sizes: [32*1024, 256*1024, 20*1024*1024], count: 3}; // in bytes
for i in range(0, cache_sizes.count) {
print_int(cache_sizes.sizes(i));
}
Writing to cache_sizes.sizes
requires cache_sizes
to be mutable: let mut cache_sizes
.
- You can use a reference to an indefinite array:
struct CS {
sizes : &[i32],
count : i32,
}
let cache_sizes = CS {sizes: [32*1024, 256*1024, 20*1024*1024], count: 3}; // in bytes
for i in range(0, cache_sizes.count) {
print_int(cache_sizes.sizes(i));
}
Writing to cache_sizes.sizes
requires then sizes
of the CS
struct to be mutable: sizes: &mut[i32]
.
from impala.
The latter does not work here (also not with making cache_size mutable), the first I already had as a work-around.
from impala.
It is not a big issue, just an annoyance.
from impala.
Originally, the idea was to support variable length arrays and flexible array members as in C99. But this has never been thoroughly implemented. Also, we'd like to change a couple of things how anydsl handles arrays in future versions anyway.
However, in the meantime I can add a check in the semantic analysis which rejects such usage of indefinite arrays.
from impala.
Sounds good, would have saved me some time ;)
from impala.
Can I close this bug with the last commit?
from impala.
Works for me. Thanks
from impala.
Related Issues (20)
- How to convert a double address to a double array adress? HOT 2
- regressions with new unit value HOT 4
- Revealing module design pattern implementation causes Segmentation Fault HOT 6
- parsing nestend lambdas HOT 2
- Type inference bug HOT 1
- Compiler segfaults for mutually recursive functions HOT 1
- Segfault when type conversions are applied within PE conditions HOT 1
- Compilation aborts when the member function of a mutable struct is called inside a higher-order function
- Compiler segfaults for recursive functions HOT 2
- match negative numbers HOT 1
- Parsing of float literals with leading decimal point returns wrong numbers HOT 1
- simple function which should specialise causes data to be copied on stack HOT 2
- Wrong ordering of memory objects for conditionals that may have side effects
- Passing closures arround beyond one call causes compiler to hang HOT 6
- Inconsistent shift behavior when shifting by 32 HOT 1
- escape sequences in string literals passed to extern functions break CUDA code generation HOT 2
- pe_assert HOT 7
- How to read user input? HOT 2
- Impala language documentation HOT 1
- Impala fails parsing inline assembly with :::
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 impala.