This repository was archived by the owner on Jun 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
mondo notation #1311
Open
felixroos
wants to merge
90
commits into
main
Choose a base branch
from
uzu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
mondo notation #1311
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- multiple args wont be interpreted as sequence anymore - you can now pass value, pat to set value to pat
- add second string type - add $ as alias for stack - simplify leaf handling
TodePond
approved these changes
Mar 19, 2025
+ allow passing a scope to MondoRunner.run + make def a side effect + proper lambda with multiple args + closure
+ add "raw" to parsed pairs + implement match + if + add more sicp examples
+ support special form for function def (might remove later) + support multiple expressions in fn body + support lexical scoping
Member
|
After discussion on discord, to consider:
I think that was the main things |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
implements a new kind of notation that combines mini notation with the ability to call functions. some links:
most mini notation features work, but there might still be bugs. would be good to get a first version out in the next release. i'd like to playtest it in nudel.cc then
features
brackets
[]=>stepcat(...args).setSteps(1)<>=>stepcat(...args).pace(1){}=>stepcat(...args)()=> function application (see more info below)infix operators
*=> fast/=> slow!=> extend@=> expand%=> pace?=> degradeBy (currently requires right operand):=> tail..=> range|=> chooseIn,or$=> stackquotes
you can use both "" and '' to get a string, where the contents can be anything (except the string delimiter itself). (escape characters currently don't exist)
comments
like in js, you can write line comments starting with "//". block comments do not exist for the time being
function application
a b # c d=>(c d (a b))applies to the left side, e.g.s bd # fast 2=>(fast 2 (s bd))(# a b)=>(lambda (_) (_ # a b))returns a lambda that transforms its input, e.g.s bd # sometimes (# crush 4)removed
a b # (c d)=>a (c d b)applies to the nearest left element, e.g.s bd # (fast 2)=(s (fast 2 bd))$=> applies function to the right, e.g.fast 2 $ s bd=(fast 2 (s bd))desugaring
all features above are "syntax sugar" for plain s-expressions. it means the parser will output a syntax tree that can only contain lists or leaf values.
Examples
mondo snippet:
strudel equivalent:
same mondo snippet with minimal number of spaces:
in the repl, mondo notation has to be enclosed with mondo`` . maybe we can find a solution to switch languages in the future. highlighting also works :)
new packages
mondowith parser and evaluator (no ties to strudel)@strudel/mondoties together mondo and strudelbreaking change: control functions call signature
this PR also comes with a breaking change:
so far, control functions would interpret multiple arguments as a sequence (fastcat). i've changed to to either accept 1 or 2 arguments. when given 2 arguments, the function will do a union. so essentially, the function then behaves like it was chained. (because mondo doesn't use method chaining)
other changes
strudelScopeobject, containing all the changes made to the global scope. it's the scope that is used for mondo evaluationregisterLanguage, allowing to add a new language that can have highlightingadd sin sqr cos aliases for signalsremovedproblems
there are some name collisions between variables in the scope and strings:
this means:
s sinewill not work, because sine will be a signal. insteads 'sine'has to be used atm... how this could be solved:things mondo cant do (yet?)
how to write lists?
how to write objects:
how to access array indices?
what else?