⚡ Sangsakala Proxy 🏠 Home
Skip to content

display doesnt work? #280

Open
Open

Description

@stchang

display doesnt seem to print unless a newline is subsequently printed after it (displayln works fine)

Example

#lang racket/base
(display 333) ; prints nothing
#lang racket/base
(displayln 333) ; prints 333
#lang racket/base
(display 333) 
(newline) ; prints 333
#lang racket/base
(display 333) 
(displayln 1) ; prints 3331

Maybe a buffer needs explicit flushing somewhere?

Activity

  1. gamburgm commented on Jan 10, 2022

    @gamburgm
    Contributor

    The buffer that needs 'explicit flushing' is NewlineFlushingOutputPort in runtime/core/ports.js.

    Thought about this a little bit and the solutions that come to mind are non-trivial. node offers process callbacks, so server-side you could write

    process.on('exit', () => flushCurrentOutputPort())

    But process isn't available in the browser. We could write a 'cleanup' function that flushes all output ports and registers/deregisters ports as current-output-port is modified or other ports are constructed, but that adds some overhead to all programs. Other option is to stop buffering altogether, but not sure if that's desired behavior.

  2. stchang commented on Jan 10, 2022

    @stchang
    MemberAuthor

    Thanks for thinking about this! I thought it would be an easy fix but then I looked into it for a while and couldnt figure it out.

    I think the argument has to be a buffer so that in the future we could possibly support the entire port api if we wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions