Forgot some updates in the readme to accompany previous commit.

This commit is contained in:
Linus 2020-11-09 13:44:55 +01:00
parent a3244a065a
commit 30b73286b3

View file

@ -44,29 +44,27 @@ Accumulators can be in any of the loop's stages:
### syntactical
all keywords are prepended with a : to distinguish them from regular variables. for -> :for
No more (for ...). Every clause is now a for-clause. This is because the addition of subloops and accumulators removed the usefulness of having a simple case that acts just as named let.
while and until are removed in favour of :break.
:when and :unless are added to better control when the loop body is executed (and accumulators accumulated)
with-clauses are removed in favour of (:for var (in init [step [stop]]))
accumulators are no longer for-clauses, but should be prepended with :acc.
with-clauses are removed in favour of (var (in init [step [stop]])) or (var (folding init [step])) in case of accumulators.
### Regressions compared to foof-loop
only :acc clauses are visible in the final-expression. This is due to for-clauses not being promoted through to outer loops (since they should not keep their state).
only accumulating clauses are visible in the final-expression. This is due to sequence clauses not being promoted through to outer loops (since they should not keep their state).
:for clauses cannot finalize, due to the above thing. The reason for distinguishing between :for and :acc is to be able to promote accumulators outwards and finalizers inwards. This is not implemented yet, however.
sequence clauses cannot finalize, due to the above thing. The reason for distinguishing between sequences and accumulators is to be able to promote accumulators outwards and finalizers inwards. This is not implemented yet, however.
Due to clause reordering, positional updates are not supported. If you want to update your loop vars, do so using named update (see below).
### changes
(with var [init [step [guard]]]) => (:for var (in init [step [stop-expr]])). guard was a procedure, but now it is an expression.
(with var [init [step [guard]]]) => (var (in init [step [stop-expr]])). guard was a procedure, but now it is an expression.
(with var 10 (- var 1) negative?) => (:for var (in 10 (- var 10) (negative? var)))
(with var 10 (- var 1) negative?) => (var (in 10 (- var 10) (negative? var)))
### similarities
@ -102,13 +100,11 @@ Named updates also work.
## Todo
Should we add finalizers for :for-clauses? I can't see the need outside of a potential (in-file ...), which can't be properly supported anyway since I won't do any dynamic-wind stuff.
Is (:for var (in init step stop)) and (:acc var (in init update)) good syntax? the :with clause of foof-loop is nice, but what should it be called for accumulators? Should we go back to calling both :acc and :for just ":for" and re-add :with and an accumulating counterpart? What should that accumulating counterpart be called? :acc?
Should we add finalizers for sequence-clauses? I can't see the need outside of a potential (in-file ...), which can't be properly supported anyway since I won't do any dynamic-wind stuff.
Add racket #:final clauses.
Add simple versions of loop. loop/list, loop/sum, loop/last, loop/first, and so on.
Add simple versions of loop. loop/list (done), loop/sum, loop/last, loop/first, and so on.
## foof, what a guy