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

Keywords #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Keywords #2

wants to merge 7 commits into from

Conversation

DerGuteMoritz
Copy link

This branch implements the keyword datatype. Keywords live in the same namespace as regular symbols but unlike them they are self-quoting. They end in :, e.g. foo: (some Scheme implementations also allow prefix notation as in #:foo; this branch only implements suffix notation though). They can be used to implement keyword function arguments. Silly example ahead:

(define (greet name . args)
  (let-keywords args ((separator ", ") enthusiastic)
    (display "Hello")
    (display separator)
    (display name)
    (display (if enthusiastic "!" "."))
    (newline)))

(greet "James")
Hello, James.
(greet "James" enthusiastic: #t)
Hello, James!
(greet "James" enthusiastic: #t separator: " ... ")
Hello ... James!

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