yamlscript

Ingy döt Net 2024-01-05T16:13:08.595699Z

Clojure allows symbols to be any combination of a certain set of characters. > Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, ', ?, <, > and = YS is much stricter. Basically it supports the style of symbols that are actually used in clojure.core. This leaves room for other syntax down the road. Currently I'm making it so that the compiler will look/lex for a valid clojure symbol, but then error if it is not a valid YS symbol or construct. The only outlier I've actually seen is stuff like foo->bar which could easily be expressed as foo-to-bar. Are there others I should be aware of?

2024-01-05T17:07:45.382549Z

We could consider the -> gimmick to be "used in clojure.core" inasmuch as defrecord Foo creates constructor functions named ->Foo and map->Foo for you.

Ingy döt Net 2024-01-05T17:09:44.680259Z

I need to learn more about defrecord.

Ingy döt Net 2024-01-05T20:12:14.893489Z

I should have said the clojure.core subset available in SCI. The map->Foo defrecord thing does work in SCI (checked with bb) I'll add that to the YS symbol rules. Is the char after map-> always uppercase? I prefer to be as strict as possible, since you can always be more lenient as needed. Here's the "weirdos" I get from bb's ns-refers:

+'
->Eduction
StackTraceElement->vec
Throwable->map
as->
bound-fn*
cond->
cond->>
inc'
list*
multi-fn?-impl
not=
read+string
tap>
I will likely elide the ones ending in ' or *. Forgot about not=...

hifumi123 2024-01-06T23:36:28.629259Z

Why not just make YS accept only munged output? This gives you about the same level of tokens as other languages (e.g. Java, JavaScript), thus retaining the flexibility you want for YS syntax

hifumi123 2024-01-06T23:37:00.876939Z

For example, (munge 'foo->bar) returns the symbol foo__GT_bar

hifumi123 2024-01-06T23:39:27.328529Z

the munged names are ultimately what gets stored in e.g. the compiled output of clojurescript files e.g. cljs.core/->Eduction refers to the javascript object cljs.core.__GT_Eduction

Ingy döt Net 2024-01-06T23:39:46.051159Z

YS doesn't even allow _

hifumi123 2024-01-06T23:40:14.689139Z

ah, that complicates things 😄

Ingy döt Net 2024-01-06T23:41:21.582059Z

Well you could substitute _ with -

Ingy döt Net 2024-01-06T23:41:51.618929Z

YS also doesn't allow --

Ingy döt Net 2024-01-06T23:42:34.902149Z

Basically it allows what people actually use

Ingy döt Net 2024-01-06T23:43:17.646119Z

And what prominent clojure actually uses

Ingy döt Net 2024-01-06T23:44:27.195659Z

What is tap> btw?

hifumi123 2024-01-06T23:54:57.953489Z

Asynchronously calls a set of "tap functions" with the inputted value. Mostly used for logging data and sending it to an external tool (like the shadow-cljs object inspector)