htdp icon indicating copy to clipboard operation
htdp copied to clipboard

Set current namespace to the current module. Fixes #208.

Open shhyou opened this issue 3 months ago • 13 comments

Fixes #208.

The pconvert printer checks the namespace for (pre-)defined symbols to decide between printing function names and (lambda (a1 a2 ...) ...) templates.

If the current namespace is not configured, as what would happen during module instantiation, user-written functions like my-add1 would be printed differently. This also affects the error message from the check-expects.

#lang htdp/isl+
(define (my-add1 n) (+ n 1))
my-add1
(check-expect my-add1 2)

Before:

Welcome to DrRacket.
(lambda (a1) ...)                                        ;; <- no good

Ran 1 test.
0 tests passed.

check-expect ... error ... :: first argument of equality
cannot be a function, given (lambda (a1) ...)            ;; <- no good

> my-add1
my-add1

This PR parameterize the current-namespace to the current module's namespace during the printing process.

shhyou avatar Oct 25 '24 13:10 shhyou