DrRacket EOPL Scheme output

社会主义新天地 提交于 2019-12-10 10:26:44

问题


I am working through the EOPL Scheme exercises using DrRacket in Windows 7. When I switch from #lang racket to #lang eopl, the output from the definitions pane no longer shows up in the interaction pane. To be clear, as trivial example, running

    #lang racket
    4
produces
    4
    >  
as you would expect. But running
    #lang eopl
    4
produces only
    > 
Is there anything I can do to change this behavior or is there another pane I should be looking at for output? I can, of course, evaluate expressions in the interaction pane and see the output, but this is tedious when I have multiple expressions I want to evaluate multiple times.

回答1:


Looks like #lang eopl uses #%plain-module-begin, which does not print results, instead of #%module-begin, which does print results.

For a quick way to switch, create the following file with the following contents:

eopl-printing.rkt:

#lang racket
(require (except-in eopl #%module-begin))
(provide (all-from-out eopl))
(provide #%module-begin)

Then use this as the language in another file:

#lang s-exp "eopl-printing.rkt"
1
2
3

produces in my DrRacket:

Welcome to DrRacket, version 5.3.4.6 [3m].
Language: s-exp "eopl-printing.rkt" [custom].
1
2
3
> 

CAVEAT: If eopl was hiding the results for a reason, then you may get some spurious output, but I don't know for sure.




回答2:


A possible workaround: print the value in the definitions pane, so it'll show up in the interactions pane. And use newline to separate lines:

(write 4)
(newline)
(write 2)

> 4
> 2

Of course, it'll be tedious if you want to display many values, but it's an improvement.



来源:https://stackoverflow.com/questions/16638024/drracket-eopl-scheme-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!