Skip to content

feat: add !x as logical NOT expression#26

Merged
danieljohnmorris merged 5 commits into
feature/caret-err-sigilfrom
feature/logical-not
Feb 27, 2026
Merged

feat: add !x as logical NOT expression#26
danieljohnmorris merged 5 commits into
feature/caret-err-sigilfrom
feature/logical-not

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

  • Adds !x as logical NOT expression in the parser
  • Connects to existing UnaryOp::Not AST node, OP_NOT VM opcode, interpreter eval, and Python codegen
  • !cond{body} negated guard continues to work (disambiguated by { following)
  • Updates SPEC.md unary operators table and TODO.md

Depends on: #25 (Err-wrap sigil migration !^)

Test plan

  • cargo clippy -- -W clippy::all — clean
  • cargo test — all 176 tests pass (163 unit + 13 integration)
  • !x parses as Expr::UnaryOp { op: Not, ... } (parser test)
  • !x in let binding: y=!x works (parser test)
  • f x:b>b;!x with truefalse (interpreter + VM tests)
  • Emits (not x) in Python codegen
  • !cond{body} negated guard still works

Now that ^ handles Err-wrap, ! is free for its expected role:
- !x in expressions parses as UnaryOp::Not (connects to existing OP_NOT)
- !cond{body} negated guard continues to work unchanged
- 5 new tests: parser, interpreter, VM, codegen
Benchmark script comparing ilo's prefix notation against Python-style
infix across 25 expression patterns. Results: 21.8% token savings,
42.4% character savings. Nested expressions show the biggest wins —
each nesting level saves 2 chars (no parens needed).
- SPEC.md: nesting examples showing how prefix eliminates parentheses
- README.md: "Why prefix notation?" section with savings summary
- MANIFESTO.md: prefix notation rationale under Token-Conservative

All link to research/explorations/prefix-vs-infix/ benchmark.
22% token savings, 42% character savings across 25 expression patterns.
@danieljohnmorris danieljohnmorris merged commit 6c76fe4 into feature/caret-err-sigil Feb 27, 2026
@danieljohnmorris danieljohnmorris deleted the feature/logical-not branch February 27, 2026 13:15
danieljohnmorris added a commit that referenced this pull request Feb 27, 2026
* feat: add !x as logical NOT expression

Now that ^ handles Err-wrap, ! is free for its expected role:
- !x in expressions parses as UnaryOp::Not (connects to existing OP_NOT)
- !cond{body} negated guard continues to work unchanged
- 5 new tests: parser, interpreter, VM, codegen

* docs: update test count to 176

* docs: update OPEN.md with ^ sigil for Err references

* research: add prefix-vs-infix token/char savings exploration

Benchmark script comparing ilo's prefix notation against Python-style
infix across 25 expression patterns. Results: 21.8% token savings,
42.4% character savings. Nested expressions show the biggest wins —
each nesting level saves 2 chars (no parens needed).

* docs: add prefix notation savings to SPEC, README, and MANIFESTO

- SPEC.md: nesting examples showing how prefix eliminates parentheses
- README.md: "Why prefix notation?" section with savings summary
- MANIFESTO.md: prefix notation rationale under Token-Conservative

All link to research/explorations/prefix-vs-infix/ benchmark.
22% token savings, 42% character savings across 25 expression patterns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant