GithubHelp home page GithubHelp logo

type printed twice in repl about racket-mode HOT 5 CLOSED

bremner avatar bremner commented on June 12, 2024
type printed twice in repl

from racket-mode.

Comments (5)

greghendershott avatar greghendershott commented on June 12, 2024

If I run Racket in an Emacs *shell* buffer, I got a similar but different issue:

$ racket
Welcome to Racket v5.93.
-> (require typed/racket)
(require typed/racket)
-> 1
1
- : Integer [more precisely: One]
1
->

It duplicates the 1 line instead of the type line.

Huh.

Looking through Typed Racket source code...


Note: The above is simply an Emacs comint-process-echoes dealio. N/A

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

This seems to be an issue using racket/sandbox and Typed Racket. IIUC Typed Racket's #%top-interaction, although from looking at ti-core so far I have no idea why.

#lang racket/base
(require racket/sandbox)

;; 1. Run this.
;; 2. In the resulting REPL, enter "1".
;; Result: The type information is printed twice:
;;     - : Integer [more precisely: One]
;;     - : Integer [more precisely: One]
;;     1

(call-with-trusted-sandbox-configuration
 (lambda ()
   (parameterize ([current-namespace (make-empty-namespace)]
                  [sandbox-input (current-input-port)]
                  [sandbox-output (current-output-port)]
                  [sandbox-error-output (current-error-port)])
     (define e (make-evaluator 'typed/racket)) ;; [^note]
     (parameterize ([current-eval e])
       (read-eval-print-loop)))))

;; [note]: Same behavior instead using make-module-evaluator:
;;   (define e (make-module-evaluator '(module m typed/racket 1)))

Either there will be some work-around (I'll ask on #racket IRC), or, I"ll have to rewrite this not to use racket/sandbox.

(Even if it's considered a bug and they fix something in sandbox and/or TR?
That would likely not be in 6, much less in 5.3.6 or lolder version, which I hope to remain compatible with.)

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

...and, this seems to be an issue that racket/sandbox has with any #%top-interaction. Even just:

#lang racket
(provide (rename-out [-#%top-interaction #%top-interaction]))
(define-syntax (-#%top-interaction stx)
  (syntax-case stx ()
    [(_ . form)
     #'(begin
         (displayln "hi, mom!")
         form)]))

So I'll look at some way of fixing or replacing racket/sandbox ...

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

So I finally tracked down what is happening. It's inside Racket's read-eval-print-loop. See source.

If I replace all this business:

                    (let ([w (cons '#%top-interaction v)])
                      ((current-eval) (if (syntax? v)
                                          (namespace-syntax-introduce 
                                           (datum->syntax #f w v))
                                          w))))))

with just this:

                    ((current-eval) v)

all is fine.

But why this "fixes" it, I'm not sure.

  1. The business of cons-ing on the #%top-interaction here seems unnecessary. Even without doing it, here, Typed Racket's #%top-interaction is being used (somehow).
  2. Since it's getting used, somehow/somewhere, apparently tacking it on here again is causing its (display type) side-effect to happen a second time here, which accounts for the double display?

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

Oh, OK. racket/sandbox does this explicitly.

Assuming I understand that correctly, then a reasonable fix will be for me to use my alternative version of read-eval-print-loop.

from racket-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.