matching now even less awkward

This commit is contained in:
Daniella / Tove 2024-11-15 14:39:36 +01:00
parent c3e2dbc1b8
commit baa981c224
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 16 additions and 0 deletions

View file

@ -716,6 +716,12 @@ func _'match-else-error { |
} }
} }
func _'match-else-push { |
if {
pop
}
}
def _'has-been-called 0 =_'has-been-called def _'has-been-called 0 =_'has-been-called
func _ { | func _ { |
_'has-been-called not if { _'has-been-called not if {

View file

@ -260,6 +260,13 @@ fn read_block_dyn(
"=" => { "=" => {
if str_words[i + 1] == ">" { if str_words[i + 1] == ">" {
i += 1; i += 1;
let pushing = if str_words[i + 1] == "?" {
i += 1;
words.push(Word::Call("dup".to_owned(), false, 0));
true
} else {
false
};
let throwing = if str_words[i + 1] == "!" { let throwing = if str_words[i + 1] == "!" {
i += 1; i += 1;
true true
@ -291,6 +298,9 @@ fn read_block_dyn(
if throwing { if throwing {
words.push(Word::Call("_'match-else-error".to_owned(), false, 0)); words.push(Word::Call("_'match-else-error".to_owned(), false, 0));
} }
if pushing {
words.push(Word::Call("_'match-else-push".to_owned(), false, 0));
}
} else { } else {
words.push(Word::Call("=".to_owned(), false, 0)); words.push(Word::Call("=".to_owned(), false, 0));
} }