Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 551363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:23:09+00:00 2026-05-13T11:23:09+00:00

I don’t understand why this code behaves differently in different implementations: (format t asdf)

  • 0

I don’t understand why this code behaves differently in different implementations:

(format t "asdf")
(setq var (read))

In CLISP it behaves as would be expected, with the prompt printed followed by the read, but in SBCL it reads, then outputs. I read a bit on the internet and changed it:

(format t "asdf")
(force-output t)
(setq var (read))

This, again, works fine in CLISP, but in SBCL it still reads, then outputs. I even tried separating it into another function:

(defun output (string)
   (format t string)
   (force-output t))
(output "asdf")
(setq var (read))

And it still reads, then outputs. Am I not using force-output correctly or is this just an idiosyncrasy of SBCL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:23:09+00:00Added an answer on May 13, 2026 at 11:23 am

    You need to use FINISH-OUTPUT.

    In systems with buffered output streams, some output remains in the output buffer until the output buffer is full (then it will be automatically written to the destination) or the output buffer is explicity emptied.

    Common Lisp has three functions for that:

    • FINISH-OUTPUT, attempts to ensure that all output is done and THEN returns.

    • FORCE-OUTPUT, starts the remaining output, but IMMEDIATELY returns and does NOT wait for all output being done.

    • CLEAR-OUTPUT, tries to delete any pending output.

    Also the T in FORCE-OUTPUT and FORMAT are unfortunately not the same.

    • force-output / finish-output: T is *terminal-io* and NIL is *standard-output*

    • FORMAT: T is *standard-output*

    this should work:

    (format t "asdf")
    (finish-output nil)   ;  note the NIL
    (setq var (read))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know why, but this code worked for me a month ago... maybe
Don't understand, if Data.Map is and [] is. I found this out while wondering
don't know better title for this, but here's my code. I have class user
Don't quite understand why this copy constructor is not invoked when I build with
Don't know how to frase this but I found this code wich works as
Don't be scared of the extensive code. The problem is general. I just provided
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been asked before, so point me to another question
Don't think that I'm mad, I understand how php works! That being said. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.