Evaluate right to left (K style)

オープン
#21 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@tangentstorm がすでに取り組んでいます。

2026年11月13日 から。

  • #22 @tangentstorm による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, compilers

調査の方向性

Start with the infix pass in im-parse.mts and the evaluator in imp-eval.mts, then trace how modifyNoun and strands run parts-of-speech steps. Read the chained-infix tests in imp-tests.org and prim-tests.org; preserve unevaluated [ ] blocks and their parse rules. Done means both example expressions produce 13 22 31, the comma case no longer fails, tests and docs reflect the new rule, and the PR explains comma behavior and changed expected outputs.

索引モデルが issue の本文から書いたものです。

説明

approved

Decision (Michal, 2026-11-09)

The default evaluator of implish must evaluate right to left, as in K. Implish stays a Logo-like language. Blocks inside [ ] are not evaluated. They can have their own parse rules.

Note: you read the code left to right, but the evaluator runs it right to left. Each verb takes everything to its right as its right argument.

Why

Today the evaluator reads infix verbs left to right with no precedence. This gives wrong results that are hard to see:

a: 1 + ! 3 ; rev a + 10 * a

This gives 13 24 33. The parser reads it as ((rev a) + 10) * a. The user wanted rev a + (10 * a), which is 13 22 31.

A second bug is in comma threading. This line fails with "expected number or vector, got: LST":

a: 1 + ! 3 ; rev a , + 10 * a

The comma takes the whole [set ; rev] list as its left argument. It must take only the clause next to it.

What to change

  1. Change the infix pass in im-parse.mts and the evaluator in imp-eval.mts so that a dyad takes the whole expression to its right as its right argument.
  2. Do the same in the code that runs the parts-of-speech steps (modifyNoun and strands).
  3. Keep [ ] blocks unevaluated. Keep their own parse rules.
  4. Decide what the comma does under the new rule. Write the answer in the PR. The line a: 1 + ! 3 ; rev a , + 10 * a must not fail.
  5. Keep the .| token free. Michal may use it later as a pipeline operator (like |> in Elixir). Do not add it now.
  6. Update every test in imp-tests.org and prim-tests.org that chains infix verbs. Explain each changed expected output in the PR.
  7. Update the front page example (rev 1 2 3 + 10 20 30) so that it still shows something clear.
  8. Update docs/evaluator.md and CLAUDE.md. They now say "left-to-right" and "no precedence".

Not in this issue

  • The b4 port (PR #3) follows in a second PR, after the TypeScript behavior is stable.
  • No deploy. Michal merges. A deploy uses the script from PR #7.

Order of work

This change goes first, on top of main. The open PRs (#3, #7, #12 to #15, #18, #19) are rebased on it after it merges.

Done when

  • Both lines at the top of this issue give 13 22 31.
  • All tests pass.
  • Docs match the new rule.
  • The PR follows the tangentcode PR standards (draft while working, MinBot check, Codex rounds, a screenshot for UI changes).
主要言語
TypeScript
スター
6
フォーク
1
平均マージ
3分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tangentcode/implish のほかの issue

tangentcode/implish の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。