12345678910111213141516171819202122232425262728293031 |
- (import (except (rnrs base) error)
- (only (guile)
- lambda* λ
- make-parameter
- parameterize))
- (define the-id (make-parameter "abc123"
- (λ (val)
- (cond
- [(symbol? val) (symbol->string val)]
- [(number? val) (number->string val)]
- [else val]))))
- (the-id)
- (define id-haver
- (λ (name)
- (simple-format #t "I am ~a! My id is: ~s\n" name (the-id))))
- ;; Call without specifying the id, implicitly uses the globally
- ;; previously defined one.
- (id-haver "Albert")
- ;; Specifying the-id.
- (parameterize ([the-id '456])
- (id-haver "Albert"))
- ;; Afterwards the-id is again the same as globally defined.
- (id-haver "Albert")
|