drym-org / qi

An embeddable flow-oriented language.
58 stars 12 forks source link

Simplify syntax-spec grammar #105

Closed countvajhula closed 1 year ago

countvajhula commented 1 year ago

From last week's Qi meetup.

Public Domain Dedication

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)

benknoble commented 1 year ago

I'll have to look again later, but it looks like there are now "floe"s and "closed floe"s. Wondering if you can comment on the difference? (Even having read the paper I sometimes have a hard time reading syntax-spec 😅.)

countvajhula commented 1 year ago

Formerly, there was floe, binding-floe, threading-floe and simple-floe, but now there is only floe and closed-floe, so it's a big improvement! The difference between the two in the new grammar is that floe may contain bindings that are active outside it, while no bindings escape closed-floe.

Re: syntax-spec, @michaelballantyne is working on a new paper that covers syntax-spec (I think the one you're talking about is more about ee-lib? Don't recall exactly), and is also writing documentation, I believe, so this may all make more sense soon :). But for the moment, I think of "nesting" (which occurs a few times in the grammar) as a kind of primitive for describing scoping rules of the DSL, if that helps.

benknoble commented 1 year ago

That helps, thanks. Maybe I was thinking of a video?

countvajhula commented 1 year ago

Today we discussed whether closed-floe and floe could be unified. An analogy here is type systems. We could explicitly indicate the type of a nonterminal or not (via nonterminal/nesting vs simply nonterminal (and there's also nonterminal/two-pass)). Doing the former allows us to cleanly handle productions constrained to one type or another (e.g. like writing an evaluator for a specific type of expression that won't need to evaluate more general expressions -- the evaluator can recur on itself rather than unnecessarily invoke the parent evaluator), provide good error messages, and simplifies the implementation of the meta-DSL. Doing the latter seems easier for the user on the face of it but incurs these various costs. Another possibility is to do a kind of "type inference" where annotations on the productions can be used to infer the nonterminal type. That works, but it doesn't allow the production to constrain the type of its subexpressions (which, I think this is something we would like to do in some cases but I'm not sure - maybe this need can be avoided?), so it's unclear if this will achieve the conceptual simplification we are looking for or would only represent a superficial compromise.

Anyway, those are some general points that came up - hope that is in some remote orbit of sense (I'm not sure). And no doubt there are many nuances that I've missed!

countvajhula commented 1 year ago

Merging this for now, though we might have some further simplifications along the lines of "type inference" coming soon 🙂