Skip to content
Snippets Groups Projects
Commit fab14ab9 authored by Michael Aaron Murphy's avatar Michael Aaron Murphy
Browse files

Enhance Assignment Parsing

There are some breaking changes with this new commit, so existing users of Ion should carefully review these changes.

Namely, at the moment the ability to perform argument swapping with the let command isn't functioning, due to some
changes to how the assignment parsing happens. I will probably bring this feature back soon, but for now it will not
work because the new assignment parsing is evaluating expressions without performing any sort of heap allocations.

Each key / value pair are now parsed one at a time, which is what made it possible to implement this without any
heap allocations. It is also the cause of the breaking change with swapping values.

It also causes another breaking change: you can't evaluate an array and have each element in the array distributed
to arguments on the left hand side. Instead, your arguments should be properly separated by spaces. When an array is
detected, then whichever variable corresponds on the left hand side will receive the entire array and be initialized
as an array, unless otherwise specified.

But what we have now gained are a significant degree of flexibility in mixing arrays among variables, among specifying
types to enable some type checking. Type checking is currently very limited though, but will soon encompass all of the
following:

- []
- str
- str[]
- int
- int[]
- bool
- bool[]
- float
- float[]

At some point, this may even be expanded to also support:

- int128
- float128
- uint
- uint128

There's also a question of whether we should roll back prior assignments when an assignment fails. Currently, I just
have the behavior set to retain prior successful assignments, but cancelling all future assignments, should there
be an error with setting values, such as an invalid type.

let a:str b c = [one two three] for five

The above should cause a type error because first variable demands to be a string and not an array. The b and c
variables are thus not set at all.
parent ce6625b2
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment