Possible Algebraic Data Types / Enum Support?
Another feature that would give Ion an advantage is to support algebraic data types / enums. We just need to figure out a syntax that would make sense for a shell language. Here's an example of how it might look like.
# Create an enum pattern
enum Action = Withdraw(amount:int) Deposit(amount:int)
while true
echo -n "Enter the action to perform"; read input
match input
case 1
echo -n "Enter amount to withdraw: "; read amount
# Assign a variable that is an enum
let action:enum = Action:Withdraw($(ftoi $amount -d 2))
break
case 2
echo -n "Enter amount to deposit: "; read amount
# Assign a variable that is an enum
let action:enum = Action:Deposit($(ftoi $amount -d 2))
break
case 3; echo "Exiting"; exit
case _; echo "Invalid Input"
end
end
# Match on a pattern that represents an enum
# Requires that all variants are handled
match action:enum
case Withdraw(amount)
echo "Withdrawing $amount"
case Deposit(amount)
echo "Withdrawing $amount"
end
No reason to not go the extra mile in creating a next-gen *nix shell.