Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildin: add flush_stdout() func #754

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@jht5945
Copy link

commented Jun 28, 2019

in default, print string to stdout has buffer, short message printed to stdout cannot display immediately, add flush_stdout() function resolve this problem

sample code:

import time

fn main() {
        print('hello ')
        flush_stdout()
        time.sleep(time.Time{ sec: 2 })
        println('world!')
}
@nxshock

This comment has been minimized.

Copy link
Contributor

commented Jun 29, 2019

IMHO print must has autoflush like in other languages.

@Compro-Prasad

This comment has been minimized.

Copy link

commented Jun 30, 2019

But there might be performance issues if we flush too often. We can have separate functions for the purpose. Something like:

  1. flush_print - for flushing after printing
  2. print - buffered printing

println by default will always flush stdout after getting a \n so we don't need to care about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.