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

Add string->symbol #80

Open
nixxon opened this issue Nov 1, 2018 · 1 comment
Open

Add string->symbol #80

nixxon opened this issue Nov 1, 2018 · 1 comment

Comments

@nixxon
Copy link

nixxon commented Nov 1, 2018

Although it's not that hard to add them on my own, (in a hacky roundabout way), I thing this 3 important functions should be included in default scheme library:

(define (macroexpand-1 exp)
  (apply (eval (car exp)) (cdr exp)))
(define (gensym . prefix)
  (if (null? prefix)
      (string->symbol (string-append "gsym_" (random-string)))
      (string->symbol (string-append (car prefix) "_" (random-string)))))

(define (string->symbol str)
  (deserialize
    (string-append "{\"type\":\"SchemeSymbol\", \"value\":\""
                   str
                   "\"}")))
(define (random-string)
  (js "Math.random().toString(36).substring(2, 15)"))
@jathak
Copy link
Owner

jathak commented Feb 3, 2019

I'm going to re-target this issue to focus on string->symbol only, since it's a useful, lowish-level procedure that requires hacks to build yourself.

As for the others, they're not in R5RS, they're not useful in a 61A-context, and they're relatively simple to build with the existing built-ins, so I'd prefer to leave them out, at least for now.

Once #83 is done, I'd be fine with an optional library of additional macro utilities, but probably wouldn't have time to implement one myself.

@jathak jathak changed the title Add macroexpand-1, gensym and string->symbol Add string->symbol Feb 3, 2019
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

No branches or pull requests

2 participants