Skip to content

Conversation

@murisi
Copy link
Collaborator

@murisi murisi commented Dec 3, 2025

Further experiments in order to try and more closely align the language interpreted to the one that is compiled. There are also some additional experiments that are not strictly necessary. Specifically, the following changes have been made:

  • The interpreter currently internally represents lists with the :list prefix (so that the internal representation matches the keyword that creates lists). This PR changes that so that lists are internally represented verbatim without a :list prefix because the tag/prefix seemed redundant.
  • Redefined car, cdr, and cons as ordinary functions defined in the environment instead of as special keywords in the interpreter. This makes the core interpreter smaller and should hopefully make it easier to align with the compiler (which also does not treat car, cons, and cdr as special keywords).
  • Combined the logic that handles self-evaluating terms like booleans and integers. This is just to try and group the self-evaluating logic and make it more concise.
  • Redefined the list keyword for constructing lists as essentially a macro that expands to nested cons calls. This might make integration with the compiler easier since it does not currently support variadic functions.
  • Redefined the apply keyword as function inside the DSL that calls a nullary function for an empty list, unary for singleton list, binary for length-2 lists, and so on. This is because it's easier to compile fixed-arity functions.
  • Stopped overloading nil as also the empty list, and instead defined null which exclusively means the empty list. This makes it easier to define list as a macro where the inner most cons's tail is the empty list.
  • Use pattern matching to match each syntactical form that can be evaluated. This might be more concise/clearer than extracting parts of a form with hds and tls.
  • Changed the way of determining whether a list is the empty list from an equality check to a newly defined is_null function. This is because equality in the compiler merely compares addresses, not the actual structures.

@murisi murisi requested a review from l4e21 December 3, 2025 14:41
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.

2 participants