example-01-basics.scm 561 B

1234567891011121314151617181920212223242526
  1. (import (except (rnrs base) error)
  2. (only (guile)
  3. lambda* λ
  4. make-parameter
  5. parameterize))
  6. (define the-id (make-parameter 'abc123))
  7. (the-id)
  8. (define id-haver
  9. (λ (name)
  10. (simple-format #t "I am ~a! My id is: ~a\n" name (the-id))))
  11. ;; Call without specifying the id, implicitly uses the globally
  12. ;; previously defined one.
  13. (id-haver "Albert")
  14. ;; Specifying the-id.
  15. (parameterize ([the-id 'def456])
  16. (id-haver "Albert"))
  17. ;; Afterwards the-id is again the same as globally defined.
  18. (id-haver "Albert")