Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lispy Syntax #58

Merged
merged 59 commits into from
Jun 29, 2024
Merged

Lispy Syntax #58

merged 59 commits into from
Jun 29, 2024

Conversation

Vandesm14
Copy link
Owner

@Vandesm14 Vandesm14 commented Jun 26, 2024

Stack is great, but having things reversed around isn't great. What if you could have both the concatenation syntax and the lispy syntax??

Functions:

  • Added a dedicated function type to ExprKind (deprecates Add a dedicated function type #52)
  • Rewrote list syntax to create functions instead of lists with fn in the beginning
  • Updated intrinsics to support functions with most list ops
  • Updated tests to use the new ExprKind

S-Expressions

  • Added an SExpr (s-expression) type to ExprKind
  • Changed lists to use [] instead of () (parenthesis are now reserved for functions and s-expressions)
  • Added parser code to parse s-expressions (similar to the aforementioned function parsing code)
  • Added underscore type to ExprKind for special s-expression syntax
  • Added auto-evaluation and eager calling of args
  • Updated existing tests
  • Added new tests
  • Updated docs

@Vandesm14 Vandesm14 marked this pull request as ready for review June 26, 2024 01:51
@Vandesm14 Vandesm14 requested a review from leonskidev June 26, 2024 01:52
@Vandesm14 Vandesm14 mentioned this pull request Jun 26, 2024
6 tasks
@leonskidev
Copy link
Collaborator

leonskidev commented Jun 27, 2024

Given the additions in this PR, I think it would make sense for lists [] to be more akin to plain old data, whilst still allowing functions and symbols to be stored within. This would mean that [1 2 +] would be stored verbatim on stack rather than eagerly evaluating to 3. If you need to call the list, you would cast it into either a function or s-expression and then call it instead.

It should also have the added benefit of only intrinsics and functions being callable, which should simplify they number of pathways for items to be evaluated internally, helping with consistency.

@Vandesm14 Vandesm14 merged commit 6750f92 into main Jun 29, 2024
1 check passed
@Vandesm14 Vandesm14 deleted the feat/lispy-syntax branch June 29, 2024 23:46
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