From 4dd4b8ff7e06c20ec43c11cfbb3dded83d902535 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 19 Jun 2025 12:44:29 -0400 Subject: [PATCH] pseudocode splatted dict algo --- src/compiler.rs | 5 +++++ src/main.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index e089273..9c95112 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -848,6 +848,11 @@ impl<'a> Compiler<'a> { self.match_depth = match_depth + members.len(); } DictPattern(pairs) => { + // here's an algorithm for dealing with splatted dicts + // check len to see it's at least as long as the pattern + // then, match against all the values + // then push the dict itself as last value + // and then emit an opcode and constant/keyword to OMIT that key from the dict self.emit_op(Op::MatchDict); self.emit_byte(pairs.len()); let before_load_dict_idx = self.stub_jump(Op::JumpIfNoMatch); diff --git a/src/main.rs b/src/main.rs index c63518a..b5eb6b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,7 @@ pub fn run(src: &'static str) { pub fn main() { env::set_var("RUST_BACKTRACE", "1"); let src = " -let (...y) = (1, 2) +let (...y) = (1, 2, 3, 4, 5) y "; run(src);