-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support other variations in feedback
syntax
#52
Conversation
|
@benknoble Thanks for taking a look! Much appreciated. I don't really have much clarity on this one, and I'm not sure it addresses the original observations by @1e1001 , even if it does make the syntax a little more flexible. Though now that I'm writing this down, I'm wondering if adding a But also, using Racket variables and syntax is another way, as in the final solution here: https://github.com/countvajhula/qi/wiki/Design-Challenge-%231#1e1001-qi-using-feedback---2 . In cases where that isn't applicable, it may be that having Qi-native bindings (i.e. instead of using Re: |
The "while" behavior can always be expressed using (feedback (while ...)) since the condition is a flow that has access to the dynamic as well as the static context, whereas the (feedback N) syntax only has access to the static context, and so it cannot use runtime values. In the light of this, it is more useful for the identifier form of `feedback` to exhibit the "N" semantics, as it allows N to be derived from runtime values.
I just realized that:
can always be rewritten to:
... since the while condition is going to operate in the context of runtime values in either case (in addition to having access to the lexical (static) context in which the On the other hand, with In the light of this, it seems that it would be better for the default identifier-only behavior to be I've made this change. Using the new "N" semantics of the identifier form of
This change is backwards incompatible, FTR. Other changes in this PR:
|
One more change: the advantage of using a With this last change, 1e1001's example becomes:
|
That last solution in particular looks quite elegant. My only feedback so far is that some of the generated syntax is quite large (lambdas, loops, etc.) that might be better off in a function (as in https://docs.racket-lang.org/style/Language_and_Performance.html#%28part._.Macros__.Space_and_.Performance%29). But that can be left for later; I didn't look to see what all the other forms were doing. |
This reduces the size of the generated syntax and consequently the memory used. See "Language and Performance" in the Racket Style Guide for more.
@benknoble I've made the change! Out of curiosity, I reverted the identifier behavior to the original "while" semantics and then ran the benchmark for
I didn't realize this could make such a difference 🤭 I'm still not really sure I understand why. Thank you for pointing it out! |
I suspect the compiler has a better chance to optimize the internals of a single, named function rather than the same code expanded all over the place. (I once read the compiler doesn't optimize anonymous functions at all.) |
That sounds plausible! Thanks for reviewing, I will merge 🙏 |
Summary of Changes
This is WIP to fix #34 .
Things remaining:
feedback
? Should it acceptN
orwhile
?feedback
andfeedback-while
forms?Public Domain Dedication