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 8017211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:46:35+00:00 2026-06-04T20:46:35+00:00

In standard Scheme it is possible to write (if (> x 2) (set! x

  • 0

In standard Scheme it is possible to write

(if (> x 2)
    (set! x (- x 1)))

but this is not possible in Racket — Racket’s if always requires two arms. Why?

  • 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-06-04T20:46:38+00:00Added an answer on June 4, 2026 at 8:46 pm

    Rationale

    The one-armed variant of if was removed from Racket to prevent bugs.

    In functional code one always uses the two-armed variant of if.

    (if test expr-on-true expr-on-false)
    

    Forgetting the second arm expr-on-false would not lead to a syntax-error, but to a runtime error (the expression would return #<void>).

    To prevent these often occurring bugs in functional code, it was decided to introduce the form when for the one-armed variant of if.

     (when test expr-on-true)
    

    Besides preventing accidental bugs, the new form clearly indicated to a reader of code, that the code relies on side effects.

    Porting code from standard Scheme to Racket

    If you try running Scheme code in Racket and see the error message

    if: bad syntax (must have an "else" expression)
    

    you must rewrite the if expression to when or unless.

    Simply rewrite:

    (if test expr1)    to    (when test expr1)
    

    and

    (if (not test) expr1)   to    (unless test expr1).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this type of question has been asked before, but I could not
What is the standard way to throw and catch exceptions in R6RS Scheme? I'm
standard power operation ( ** ) in Python does not work for negative power!
The standard RadioButton does not support setting the color of the ellipse. So, I
I have two tables with the exact same schema in SQL Server 2008 Standard
Is it possible to define a standard ServiceHostFactory foreach 'workflow' service (xamlx) Our customers
I've written a small Scheme interpreter in an unholy mix of C/C++, but I
Is it possible to upload a 0 byte file to Amazon S3? My standard
I have a standard code like below to validate xml against xsd, but it
I have a standard store schema with an InvoiceLine table that contains Products. I'd

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.