Is #%top <https://docs.racket-lang.org/reference/__top.html> what you are looking for?
#lang racket (require syntax/parse/define) (define-simple-macro (#%top . x) 'x) (define x 42) x ;=> 42 y ;=> 'y (string-length (symbol->string abcdef)) ;=> 6 Unbound identifiers are wrapped with #%top during expansion steps <https://docs.racket-lang.org/reference/syntax-model.html?q=%23%25top#%28part._expand-steps%29>, so you can define #%top to deal with unbound ids. For instance, Pollen <https://pollenpub.com> by default uses #%top to create default tags <https://docs.racket-lang.org/reference/__top.html>. On Thu, Jun 20, 2019 at 9:23 PM Kevin Forchione <lyss...@gmail.com> wrote: > Hi guys, > Every now and then I wonder about the decisions behind the languages we > work with and of late I’m wondering about symbols. By default symbols > reveal their binding value unless you explicitly tell them not to — in > other words unless you quote them. And that’s pretty useful. In macros I > can control this behavior by taking my symbol and wrapping a quote around > it. And I’ve even had some good results with guards using > identifier-binding to determine whether I need to do that or not — though > I’m not sure about the limitations and contextual restrictions of that > approach — there’s nothing that simply says “if this symbol is exposed to > evaluation it’ll produce a binding exception so we’ll wrap it in a quote > for you” sort of mechanism that I’m aware of… at least not one that > doesn’t require some qualification.And there’s the other approach that I’m > playing with now as well: wapping symbols in quotes by default unless I > explicitly state not to — a sort of unquote passed into the macro syntax > that makes the syntax look a little like MDL, but I haven’t worked out all > the kinks in that approach yet. And of course sometimes I’d like to just > toss symbols around without having a bind to worry about — keywords I > suppose, but without the association to function arguments — just something > to compare or key on. I suppose there’s probably a way to do this with the > reader, though I haven’t looked into that much yet. And finally there’s the > common lisp itch I get from time to time to have symbols with bindings and > plist sort of associations — parameterized hash tables to store the values > perhaps. > > In all this meandering, the question is whether there are libraries doing > these sorts of things already? It’s fun to re-invent the wheel at times, > but also instructive to learn while standing on the shoulders of giants, so > to speak, and creatively stimulating. :) > > Kevin > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/EB9B5188-4B62-42BB-B24F-2B95166E95F7%40gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CADcuegvT5013YWNKo3h6xEpXRYWtz_mpwbWPu1bRJbenObg_kg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.