-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsrfi-258.sls
32 lines (27 loc) · 996 Bytes
/
srfi-258.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;; SPDX-FileCopyrightText: 2025 Wolfgang Corcoran-Mathe
;;; SPDX-License-Identifier: MIT
;;; SRFI 258: Uninterned symbols
;;; Wrapper implementation for ChezScheme.
(library (srfi :258 uninterned-symbols)
(export string->uninterned-symbol symbol-interned?
generate-uninterned-symbol)
(import (rnrs base)
(rnrs control)
(only (chezscheme) uninterned-symbol?
string->uninterned-symbol
random))
(define (symbol-interned? sym)
(assert (symbol? sym))
(not (uninterned-symbol? sym)))
(define generate-uninterned-symbol
(case-lambda
(() (generate-uninterned-symbol ""))
((prefix)
(assert (or (string? prefix) (symbol? prefix)))
(let ((r (random (expt 2 128)))
(p (if (symbol? prefix)
(symbol->string prefix)
prefix)))
(string->uninterned-symbol
(string-append p (number->string r)))))))
)