dynamic import in REPL + implicit mini notation + patternable aliases #172
Replies: 27 comments 5 replies
-
imports are not supported (yet?). We use shift-ast, which supports import, but for that we need a custom implementation of loading scripts on the fly, which we do not have yet. There was a discussion recently about loading scripts: #153 (search In case you want to do the ceremony, here is a setup guide: https://github.com/tidalcycles/strudel/blob/main/CONTRIBUTING.md#project-setup |
Beta Was this translation helpful? Give feedback.
-
I've actually done basically this exact work in another REPL-type project, would you want a PR? |
Beta Was this translation helpful? Give feedback.
-
yes please! which types of modules did you manage to load with it? |
Beta Was this translation helpful? Give feedback.
-
Any valid native JS module works fine. Like you could do something like |
Beta Was this translation helpful? Give feedback.
-
that would be nice! feel free to ask any questions that may arise |
Beta Was this translation helpful? Give feedback.
-
OK so after further investigation this is not really possible with the current REPL. At the moment, the Off the top of my head, here are a few possible solutions:
This is still pretty terse & doesn't break JS semantics.
Personally my vote would be for option 1 because I'm a JS dork and don't like people tampering with the crystalline perfection of the One True Language, but I realize this may be a minority view. |
Beta Was this translation helpful? Give feedback.
-
You can still use single quotes for ordinary strings, so you can still write every possible javascript program!
Another path that can work is to parse strings with mini by default in all strudel functions, so the string magic is not needed. I am not a huge fan of this idea because you cannot use all these characters: * / : < > [ ] { } | and space, as they are used by the mini language. So you cannot use 'C minor', because you'll get seq('C', 'minor'). It can be worked around by adding replacements for special chars, like _ for space etc.. but this can get confusing quickly |
Beta Was this translation helpful? Give feedback.
-
FWIW I think it makes a lot of sense to have easily tokenisable chord labels. I haven't seen the convention with spaces before and find it difficult to read. I think it would be great if strudel's chord labels would match Tidal's, especially if that involved improving Tidal's representation of chords. |
Beta Was this translation helpful? Give feedback.
-
I was talking about scales, not about chords. Using spaces for scales is quite common, like 'C minor', 'G mixolydian' etc.. The names are referencing tonaljs scales, where even the scale names itself can have spaces. Chords are currently implemented in the form of voicing dictionaries, using the chord-voicings package. The chord symbols are in theory freely configurable although the configuration is not (yet) exposed through strudels voicings API. Having them freely configurable gives the user the freedom to use any spelling. But of course there should be a good standard set, tbh I do not really like using chord symbol names that are constrained to use the format of variable names (like tidal does afaik). One widely used format for chord symbols is this (check out the ireal forum, there are thousands of chord changes using that set of symbols, at least if you know how to decrypt the links). It also pretty closely resembles the way many musicians would write down the chord on a lead sheet. But this does not mean we still can support the chord symbol set of tidal (for tidalists that are already familiar with those). All of the above might be worth a separate discussion, so coming back to the question if mini notation should be parsed at all times (eliminating the need to shapeshift double quoted strings):
In a broader sense, this is not only about being able to use scale names with spaces, but about having the freedom to use strings freely for anything (not only music). It just feels like too big of a cost having to work around the limitations of the mini notation (aka don't use any of * / : < > [ ] { } | ' ' in your strings). edit: @yaxu what do you mean by "easily tokenisable" and why is it that important? |
Beta Was this translation helpful? Give feedback.
-
Ah sorry I get mixed up between all these different collections of notes ! I guess I mean then that it would be nice to have scale names that don't have whitespace in so that they can be patterned with the mininotation. If all arguments are patterns then things are a bit simpler. |
Beta Was this translation helpful? Give feedback.
-
OK I didn't realize that the string substitution was only for double quotes! This is a great example of where knowing JS is actually a bit of a disadvantage with this app LOL. So I think we agree that adding a desugaring directive of some kind is a good way to go. How about |
Beta Was this translation helpful? Give feedback.
-
Although I admit the combination of "strudel" and "sugar" is rather pleasing... |
Beta Was this translation helpful? Give feedback.
-
No worries, in the end, scales and chords mean the same thing.. My argument is still that we would introduce a big limitation by parsing all strings. Let me make my point clear with some examples: I would rather write
Also, what about slash chords: If everything is parsed, writing What if I want to make flashy html visuals, which I could do now with:
What if I want to use a microtonal ratios similar to xenpaper:
What if I want to use any alternative DSL inside a pattern function? |
Beta Was this translation helpful? Give feedback.
-
Good point with single line rules..
I also like the sugar reference but maybe that category is too broad, because the syntax sugar involves more than just double quote to mini, and I think each thing should be controllable separately. There could also be an option that disables everything, but e.g. top level await and highlighting are desirable in most cases |
Beta Was this translation helpful? Give feedback.
-
speaking of, we could also add |
Beta Was this translation helpful? Give feedback.
-
explicit mini functionality is already be implemented in #99 (minifyStrings flag) |
Beta Was this translation helpful? Give feedback.
-
You could do:
perhaps we could make 'pure' versions of all the functions
|
Beta Was this translation helpful? Give feedback.
-
hm then we would need pure versions of each function and each method.. Using strudel without the shapeshifter as it works now requires you to use just 1 more character (m) for mini patterns, which is not that bad. If we really wanted to trim down that character for that use case, we could add some flag to the core package, that will run each reified string through mini. But I also don't really understand why the shapeshifter would be a problem, if things can also be turned on and off within the eval package. |
Beta Was this translation helpful? Give feedback.
-
one thing that the *pure functions cannot do: |
Beta Was this translation helpful? Give feedback.
-
we could also flip things and add *mini functions like |
Beta Was this translation helpful? Give feedback.
-
Yes I think the "/' difference is fine too and don't really think making pure versions of everything is the answer, just thinking aloud. I still think it would be better if labels for scales etc had simple enough identifiers to be able to be patterned with the mini-notation though. |
Beta Was this translation helpful? Give feedback.
-
Totally agree, though I'd say we should not take away the more conventional but less patternable aliases |
Beta Was this translation helpful? Give feedback.
-
OK well it seems like the directive is on it's way so I'm gonna leave that tangent alone. And now that I know I can use single-quotes for normal non-magic strings, I think I have a simple fix for the |
Beta Was this translation helpful? Give feedback.
-
I don't see the value of them really - if an alias is less patternable, then that creates a barrier to change.. You have to edit the label if you later decide you want to pattern it. Their presence in examples makes strudel look less like a system for patterning and more like a conventional step sequencer. |
Beta Was this translation helpful? Give feedback.
-
ok here's an another idea: what if the mini notation had a high precedence character that marks a 'parse free zone', like: "0 2 4".scale("'C major' ['D dorian' 'G mixolydian']") With that, you can use any character you like inside
With that, we won't need to rewrite any data that needs to be patterned. I also like how the single quotes still mean 'ordinary string' wether inside or outside double quotes edit: it's funny to think about strings in programming languages as "a high precedence character that marks a 'parse free zone'" |
Beta Was this translation helpful? Give feedback.
-
just realized that implicit minification is already pretty simple to do: |
Beta Was this translation helpful? Give feedback.
-
@debrisapron imports are now live https://strudel.tidalcycles.org/?7DsklCccTr-k 🎉 |
Beta Was this translation helpful? Give feedback.
-
I want to import code from e.g. jsdelivr in the REPL but I get an
Unexpected token "import"
message. Does the JS parser the REPL uses not support import? This would be super helpful for prototyping plugins for Strudel without the whole ceremony of forking the repo, creating a dev environment etc etc.Beta Was this translation helpful? Give feedback.
All reactions