Feature: Ability to specify and cast types #33
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It would be good to have a way to specify the type of a variable like
a : int8 = 1
Also a casting function would be great too so you can have array of integeres
Currently mem.alloc only returns a string you cant manipulate outside of the scope
fizz(arr string) {
arr[1] = 'b' // Doesnt work
}
main() {
arr := mem.alloc(8)
arr[0] = 'a' // Works
fizz(arr)
mem.free(arr)
}
Added in
00d014155d.Notes:
This issue contains 2 independent problems.
I personally prefer it when each problem gets its own issue, but it is what it is.
Here are the solutions:
1.) Casting to types
This should be possible now:
Note that this works with primitives but not with structs.
2.) Not being able to write to allocated strings in another function.
There needs to be some mechanism to determine which writes are safe.
However, I've removed the current restriction because it's too restrictive.
Do you think the issue can be closed or is there anything that you would like to add?
I think issue can be closed, also sorry for saying 2 problems in 1 issue