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

  • Home
  • SEARCH
  • 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 8553231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:36:16+00:00 2026-06-11T14:36:16+00:00

I am following this draw_string_in_box example in Developing Applications with OCaml The sample code

  • 0

I am following this draw_string_in_box example in Developing Applications with OCaml

The sample code given is as follows:

let draw_string_in_box pos str bcf col = 
 let (w, h) = Graphics.text_size str in
 let ty = bcf.y + (bcf.h-h)/2 in 
 ( match pos with 
       Center -> Graphics.moveto (bcf.x + (bcf.w-w)/2) ty 
     | Right  -> let tx = bcf.x + bcf.w - w - bcf.bw - 1 in 
                 Graphics.moveto tx ty 
     | Left   -> let tx = bcf.x + bcf.bw + 1 in Graphics.moveto tx ty  );
 Graphics.set_color col;
 Graphics.draw_string str;;

If I remove the parentheses around the “match” part, the code won’t work (nothing gets printed). Any idea why?

And more generally, when should I put parenthese around code bits like this?

Thanks.

  • 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-11T14:36:17+00:00Added an answer on June 11, 2026 at 2:36 pm

    One way to look at it is that after the arrow -> of a match statement you can have a sequence of expressions (separated by ;). Without the parentheses, the following expressions look like they’re part of the last case of the match.

    You can also have a sequence of expressions (separated by ;) after let. With the parentheses, the following expressions look like they’re part of the let, which is what you want.

    Personally I avoid using ;. That’s how I deal with this problem! Otherwise you have to figure the expression sequence goes with the innermost construct that takes a sequence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following this code my button works perfectly: http://twitter.github.com/bootstrap/javascript.html#modals Fades and everything. I want to
Given the following code. Is there any potential for the first DrawString method to
I am following the first example in this tutorial: http://ruportbook.com/printable_documents.html , but I'm getting
I have setup a simple Google Chart by following the example on this page:
I have the following input data in String: Hello #this# is #sample# text. It
Following this question and answer , I still have a bit trouble in the
Following this discussion , I've encountered a bad access issue; A loop has several
following this link i was able to load and read pixels from a .gif.
Following this tutorial and running into trouble. [TestMethod] [ExpectedException(typeof(Exception))] public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() { var
Following this thread, I tried to upload a file on the server. If 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.