Skip to content
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

run james using scheme macros (counter example) #4

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

dckc
Copy link
Contributor

@dckc dckc commented Jan 10, 2025

refs:

The counter example runs; I'm writing ($ rx m args ...) instead of (rx .m args ...)

($ console log "\nTesting counter with offset:")
(module
  (define make-counter
    (fn (init)
      (var value init)
      (return (%r
               (: increment (fn () (+= value 1)))
               (: decrement (fn () (-= value 1)))
               (: makeOffsetCounter
                  (fn (delta)
                    (return (make-counter (+ value delta)))))))))
  (define c1 (make-counter 5))
  ($ console log "Initial counter at 5")
  ($ c1 increment)
  ($ console log "After increment:" ($ c1 decrement))
  (define c2 ($ c1 makeOffsetCounter 10))
  ($ console log "New counter with +10 offset")
  ($ c2 increment)
  ($ console log "After increment:" ($ c2 decrement)))

output:

Testing counter with offset:
Initial counter at 5
After increment: 5
New counter with +10 offset
After increment: 15

full disclosure: my scheme-fu is weak, so I leaned on aider with --sonnet for most of the details.
The git log shows which parts it wrote and which parts I did by hand.

IOU the chat log. It might serve as an interesting record of somebody learning scheme.

dckc added 30 commits January 9, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant