Commit graph

17 commits

Author SHA1 Message Date
Linus
189f1d045d Made sure loop loops
Fix subloop :acc semantics.

clarify code comments.
2021-05-25 22:07:53 +02:00
Linus
307240383a Changed semantics of pure loop form
Now an empty clause list means execute body once.

any kind of clause means: loop. regardless of for or no for clause.
2021-05-23 22:10:23 +02:00
Linus
e057a6b8fe loops without subloops can now use :for clauses in final-expr 2021-05-21 20:42:10 +02:00
Linus
93134a1b21 Made => implicit if we have accumulators
If there are accumulators, their final values will be returned if no
final-expr is given.

(loop ((:for a (up-from 1 11))
       (:acc lst (listing (* a a))))
  => lst)

becomes simply:

(loop ((:for a (up-from 1 11))
       (:acc lst (listing (* a a)))))
2021-05-18 20:39:37 +02:00
Linus
7a1137e579 Changed accumulator test/bind order to bind/test
This means vectoring exits directly when the index loop variable =
:length.

It also means :final has to change.
2021-05-18 19:57:02 +02:00
Linus
2c323be362 Big change: lexical scoping
This introduces lexical scoping of for clauses. See README.md
2021-05-18 18:12:01 +02:00
Linus
769553832b Start of something big
This marks a deviation from the foof-loop inheritance, and a path
towards a more lexical scope. :for clauses are now bound to the top of
each loop, and the following :bind, :when, :unless, :break, :final and
:acc clauses now follow a the lexical order of when they were
introduced... At least, that's the plan. This commit makes :for, :bind,
:when, :unless and :break work. The rest is broken.

and :let+:let* are no more.
2021-05-16 20:13:55 +02:00
Linus
3908019bbc Added some tests.
Fixed some things I noticed when testing the tests.
2021-03-22 19:30:09 +01:00
Linus
5847bd21d4 Fixed :final and make to, by => :to :by
I had a bug. I had an inconsistency. Don't worry. All is fixed.
2021-03-18 12:41:39 +01:00
Linus
f6d7b01793 Refactored for-clauses to take :for for better error reporting
At least in the future
2021-03-16 19:30:08 +01:00
Linus
172d0aa180 Changed the loop protocol for :acc clauses
The third clause (the "check" clause) now breaks the entire
iteration for :acc clauses instead of just exiting the current subloop.

This is much saner, and was immediately usable in vectoring.
2021-03-11 22:18:29 +01:00
Linus
79b7c4eedd Clarified expansion
The expansion of (loop ...) without subloops is now the same as loop
with subloops.
2021-03-11 14:35:07 +01:00
Linus
7b3814c430 More parentheses
I have changed my mind about the clause forms. They should, with the
exception of :subloop, be parethesised: :when test => (:when test).
2021-02-18 21:19:12 +01:00
Linus
a545c1cbd7 Fix a bug where simple loops did not bind let bindings correctly
add check whether a loop clause exists to avoid the ultra-shit errors that happen if you
accidentally write (up-form ...)
2021-02-09 22:02:40 +01:00
Linus
d48ed19e43 Fix the previous commit. Now also the simple loops are ensured to execute once if no for-clauses are given.
Instead of throwing a syntax-error...
2021-01-28 20:37:05 +01:00
Linus
685fe86f36 Loops without any clauses now run the body at least once.
Small updates to readme.
2021-01-28 20:18:15 +01:00
Linus
06a11fc892 Modularized the code
Everything in goof-impl.scm is portable (r7rs) syntax-rules. The non-portable parts
, most notably the let-kw-form macro is in the module definition goof.scm.
2021-01-28 20:01:24 +01:00