arturo-lang / arturo

Simple, expressive & portable programming language for efficient scripting
http://arturo-lang.io
MIT License
673 stars 29 forks source link

Start choose migration #1646

Closed RickBarretto closed 1 month ago

RickBarretto commented 1 month ago

Description

This PR is not meant to be an implementation of the choose function itself, and this does not remove the target functions that will be deprecated soon.

Basically, the way if?, else, case, when? works is very problematic. Since they depends on each other, and should be independent. Other problem is the fact that else and when? violates the way the stack really works, so this is a valid code:

false
else -> print "Whut??"
; Whut??

And as we may know, this can lead to hidden bugs in a lot of code. That is the reason why me and @drkameleon were avoiding for a long time to use those functions.

So, this is time to change. But first things, first. We need tests first, to check if the behavior is what we desire, then we need to implement that function and then we need to optimize it.

Worth to say, that choose will replace all of them into once.

Type of change

RickBarretto commented 1 month ago

I changed a lot of examples at once, I hope I didn't break anything... :gezz:

RickBarretto commented 1 month ago

Ok, cancelling this PR... image