Running format procedure code example results in error

Typing one of the code example for format in DrRacket returns error.

Racket version: 9.0
Language: BSL
Documentation link: format

Code: (format "the value of ~s is ~a" '(+ 1 1) (+ 1 1))
Error: quote: expected the name of a symbol or () after the quote, but found a part

'(+ 1 1) is beyond the BSL level. The only valid syntax is having name or a () after ', e.g., 'apple. So this works:

#lang htdp/bsl
(define apple "🍎")
(format "the value of ~a is ~s" 'apple apple)

But not this:

(format "the value of ~s is ~a" '(+ 1 1) (+ 1 1))

To allow expressions like '(+ 1 1), the minimum level needed is Beginning Student with List Abbreviations:

#lang htdp/bsl+
(format "the value of ~s is ~a" '(+ 1 1) (+ 1 1))

Thank you for the quick reply. I guess the documentation for BSL format needs to be updated to remove that particular example.

Take a look. The grammar of BSL allows ' (quote) in two places:

  • '()
  • 'name

That's it.

Following up on my own post:

I see the format comes with this misleading example.
Thanks for pointing out this example. I have removed it.