diff --git a/may_2025_thoughts.md b/may_2025_thoughts.md index 1458860..1864101 100644 --- a/may_2025_thoughts.md +++ b/may_2025_thoughts.md @@ -494,7 +494,7 @@ Here's a list of things that need doing: - I need this fixed for optimization reasons. - I _think_ I just fixed this by fixing tail position tracking in collections - [ ] test this -* [ ] Dict patterns are giving me stack discipline grief. Why is stack discipline so hard? +* [x] Dict patterns are giving me stack discipline grief. Why is stack discipline so hard? * [ ] This is in the service of getting turtle graphics working * Other forms in the language need help: * [ ] repeat needs its stack discipline updated, it currently crashes the compiler diff --git a/sandbox.ld b/sandbox.ld index 3c9996a..fc48bd5 100644 --- a/sandbox.ld +++ b/sandbox.ld @@ -1,4 +1,4 @@ -let state = #{:position (0, 0), :heading 0, :pencolor :white} +& let state = #{:position (0, 0), :heading 0, :pencolor :white} & let command = (:forward, 10) @@ -35,5 +35,11 @@ let state = #{:position (0, 0), :heading 0, :pencolor :white} & & (:background, _) -> state & } +box foos = [] +repeat 4 { + update! (foos, append (_, :foo)) +} + +do foos > unbox > count diff --git a/src/compiler.rs b/src/compiler.rs index 657f9f4..a66ece8 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -1242,7 +1242,7 @@ impl<'a> Compiler<'a> { // begin repeat self.emit_op(Op::Decrement); let repeat_begin = self.len(); - self.emit_op(Op::Duplicate); + self.duplicate(); let jiz_idx = self.stub_jump(Op::JumpIfZero); // compile the body self.visit(body); diff --git a/src/main.rs b/src/main.rs index 52d8542..70eb87e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,8 +112,8 @@ pub fn run(src: &'static str) { // in any event, the AST should live forever let parsed: &'static Spanned = Box::leak(Box::new(parse_result.unwrap())); - // let prelude = prelude(); - let prelude = imbl::HashMap::new(); + let prelude = prelude(); + // let prelude = imbl::HashMap::new(); let mut validator = Validator::new(&parsed.0, &parsed.1, "user input", src, prelude.clone()); validator.validate();