Re: [racket-users] Why do single-form modules behave differently?

2021-01-02 Thread Michael MacLeod
--- Original Message > On Jan 3, 2021, 12:18 AM, Michael MacLeod < michaelmmacl...@gmail.com> > wrote: > > > There's an edge case of 'module' when only one form is provided which > results in that form being partially expanded to determine if such > expansion w

Re: [racket-users] Why do single-form modules behave differently?

2021-01-02 Thread Michael MacLeod
There's an edge case of 'module' when only one form is provided which results in that form being partially expanded to determine if such expansion would lead to a #%plain-module-begin form. Otherwise (more than one form provided) they are wrapped in #%module-begin with no partial expansion

Re: [racket-users] provide-if-not-defined

2020-09-02 Thread Michael MacLeod
Does this example work: http://pasterack.org/pastes/95923? `if-not-defined` is written as a provide transformer which uses `syntax-local-module-defined-identifiers` to get the list of phase-0 identifiers defined in the module. Best, Michael [code also pasted below]: #lang racket/base (module

Re: [racket-users] require and syntax-case

2020-07-12 Thread Michael MacLeod
The issue isn't actually with the `(_ (x y))` pattern---it's with the `#'(require (x y))` template. When `require` is passed a module path like `(file "test1.rkt")`, it introduces any identifiers [just `ok` in this case] with the same lexical context of the module path itself[1]. The issue is

Re: [racket-users] Matching groups of optional elements

2020-05-04 Thread Michael MacLeod
I'm not sure this is possible with only using `match` patterns. A combination of the `list-rest` and `app` patterns as well as the `in-slice` procedure from `racket/sequence` should do the trick, though: #lang racket (require racket/match) (define (collect-optional-vals x) (for/list ([y

Re: [racket-users] DrRacket and command line arguments

2020-04-18 Thread Michael MacLeod
You can parameterize `current-command-line-arguments` like so: ``` #lang racket (require racket/cmdline) (define foo (make-parameter 7)) (parameterize ([current-command-line-arguments #("--thing" "9")]) (command-line #:program "foo" #:once-each [("--thing") thing "The thing" (foo

Re: [racket-users] Starting racket with at-exp

2020-03-02 Thread Michael MacLeod
$ racket -i -l scribble/reader -e "(use-at-readtable)" -l your-lang-without-@-support should do the trick. For example, to start a REPL in typed/racket with @-reader support, you would use: $ racket -i -l scribble/reader -e "(use-at-readtable)" -l typed/racket > @+[2 3] - : Integer [more

Re: [racket-users] perplexed by macro-expansion behavior near #%module-begin

2020-01-13 Thread Michael MacLeod
I believe this due to an edge case of 'module': when there is only one form provided, it is partially expanded to determine if its expansion would lead to a #%plain-module-begin form. Otherwise (more than one form provided) they are wrapped in #%module-begin with no partial expansion occurring.