4

I want a language like scribble/text but with some additional functions offered. This is what I've tried:

#lang racket/base

(require scribble/text)
(provide (all-from-out scribble/text)
  hello)

(define (hello name)
  (format "Hello ~a!" name))

When I try to run a module written in this language, I get a message saying that there is no #%module-begin binding in the module's language.

I assume that scribble/text has a binding for #%module-begin, else how does it work when I use it as a #lang?

Maybe scribble/text knows that I am importing it using 'require' rather than as a #lang, and so I don't automatically get the #% macros? If that's the case, then how would I get them and re-export them?

Or is something else happening here?

Richard Parsons
  • 277
  • 1
  • 9
  • What does “a module written in this language” mean, precisely? That is, what does the `#lang` line look like in the other module? – Alexis King Jul 14 '19 at 22:48
  • The original module is in a file called notebook/main.rkt, and the second file is written in it using the line "#lang notebook". What difference does it make? – Richard Parsons Jul 15 '19 at 06:31

1 Answers1

4

The language for #lang scribble/text and the library for (require scribble/text) are different modules. The library version doesn't provide #%module-begin or the other bindings from racket:

When scribble/text is used via require instead of #lang, then .... it does not include the bindings of racket/base ....

The module-language #lang scribble/text actually uses is scribble/text/lang. So you can fix your module-language like this:

#lang racket/base

(require scribble/text/lang)
(provide (all-from-out scribble/text/lang)
         hello)

(define (hello name)
  (format "Hello ~a!" name))

However, the module scribble/text/lang is undocumented, so use at your own risk.

Alex Knauth
  • 8,133
  • 2
  • 16
  • 31