@notjack You’re thinking of http://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Plural%29, which says “Avoid plural when naming collections and libraries. Use racket/contract
and data/heap
, not racket/contracts
or data/heaps
.” Though I think racket/math/constants
is a natural choice: it provides several distinct mathematical constants, whereas data/heap
provides a general heap data structure.
ah! that’s a good point. I don’t like constants
anymore
I have this dilemma when it comes to SQL table names — singular or plural? select blah from users
reads naturally. [As does (select blah #:from users)
— thanks @ryanc !] On the other hand, a table is obviously plural, so do I type “s” or weird English pluralizations everywhere for no dang reason? On the third hand, USER
is a reserved word so for singular now I need quotes. So I just go have a good cry about how naming things is hard.
Then there’s Rails, which will attempt to automatically pluralize your Ruby class names to generate database table names. :)
Ruby on Rail datumbase :slightly_smiling_face:
Flip a coin :slightly_smiling_face: that’ll help
For what it’s worth, I go with singular since I see it as a natural carry over from set theory where sets are traditionally written as singular. So yeah basically I’m delegating my reason to historical underpinnings of set theory.
@mflatt Is there any way to add a module’s scope to a syntax object without actually requiring the module? Something like a syntax-local-lift-require/declare
.
Basically, I want to be able to do something like this:
#lang scratch ; blah.rkt
(define f 5)
(define-syntax-parser g
[(_)
(syntax-local-lift-require
"bla.rkt"
(datum->syntax #f 'f))])
(g)
(Obviously this will give a circular require error, but all I realy care about is the bla.rkt
scope.)
(Also I know in this particular case it will have the module scope already.)
@mflatt Although I guess a little mor precisely I’m looking to make a macro like this:
(define-syntax-parser g
[(_ mod name)
(syntax-local-lift-require
(syntax->datum #'mod)
(datum->syntax #f (syntax->datum #'name)))])
@leif Terminology clarification: require
doesn’t get a module’s scope; it adds bindings to some scope – either the scope of a module body that uses require
or a fresh scope in the case of syntax-local-lift-require
— based on a module’s exports. I’m not sure what you have in mind by “without actually requiring” the module. Are you trying to avoid instantiation, in which case a for-label
import might be the way to go? Or are you just trying to inspect the exports, in which case module->exports
could be the right tool?
Basically, I’ve serialized a pair of a module path index (which I can resolve to a module path), and a symbol. I want to create and call an identifier from this pair.
I would have serialized the identifier directly, but obviously that won’t work. :slightly_smiling_face:
I could normally just use syntax-local-lift-require
to turn the module path and symbol into an identifier. But that is a problem when the module path it points to is itself.
Does that make a little more sense?
I may guess wrong at what “call an identifier” means, but why is syntax-local-lift-require
not what you want?
Oh…err…I mean, expand to an identifier.
And syntax-local-lift-require
errors when I have something like this:
#lang racket ;; loop.rkt
(require syntax/parse/define)
(provide x)
(define x 5)
(define-syntax-parser exp
[(_ mod sym)
(syntax-local-lift-require
(syntax->datum #'mod)
(datum->syntax #f (syntax->datum #'sym)))])
(exp "loop.rkt" x)
Understandably gives this error: . . ../racket/racket/collects/syntax/wrap-modbeg.rkt:46:4: standard-module-name-resolver: cycle in loading
at path: /Users/leif/test/loop.rkt
paths:
/Users/leif/test/loop.rkt
@jedgingt has joined the channel