philip.mcgrath
2018-7-22 08:49:35

@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.


ben
2018-7-22 16:33:22

ah! that’s a good point. I don’t like constants anymore


greg
2018-7-22 17:33:57

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.


lexi.lambda
2018-7-22 17:55:41

Then there’s Rails, which will attempt to automatically pluralize your Ruby class names to generate database table names. :)


greg
2018-7-22 18:14:40

Ruby on Rail datumbase :slightly_smiling_face:


abmclin
2018-7-22 18:26:52

Flip a coin :slightly_smiling_face: that’ll help


abmclin
2018-7-22 18:31:03

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.


leif
2018-7-22 23:19:10

@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.


leif
2018-7-22 23:19:54

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)

leif
2018-7-22 23:20:43

(Obviously this will give a circular require error, but all I realy care about is the bla.rkt scope.)


leif
2018-7-22 23:22:22

(Also I know in this particular case it will have the module scope already.)


leif
2018-7-23 00:05:20

@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)))])

mflatt
2018-7-23 01:05:25

@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?


leif
2018-7-23 01:08:28

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.


leif
2018-7-23 01:08:50

I would have serialized the identifier directly, but obviously that won’t work. :slightly_smiling_face:


leif
2018-7-23 01:09:57

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.


leif
2018-7-23 01:10:04

Does that make a little more sense?


mflatt
2018-7-23 01:33:39

I may guess wrong at what “call an identifier” means, but why is syntax-local-lift-require not what you want?


leif
2018-7-23 01:36:29

Oh…err…I mean, expand to an identifier.


leif
2018-7-23 01:36:45

And syntax-local-lift-require errors when I have something like this:


leif
2018-7-23 01:39:12
#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)

leif
2018-7-23 01:39:43

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
2018-7-23 01:55:31

@jedgingt has joined the channel