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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:28+00:00 2026-06-17T12:44:28+00:00

Since OCaml has different operations for multiplying integers and doubles, how it can be

  • 0

Since OCaml has different operations for multiplying integers and doubles, how it can be object-oriented? Doesn’t this mean OCaml has no polymorphism?

  • 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-17T12:44:29+00:00Added an answer on June 17, 2026 at 12:44 pm

    Yes, OCaml has polymorphism. Here are some reasons why arithmetic operations aren’t implemented as polymorphic methods:

    1. Integers and doubles aren’t objects in OCaml, so they can’t have methods.
    2. Operators in OCaml are functions, not methods. Of course the language could have been designed to make them methods instead, but then you could not define custom operators for anything that isn’t an object.
    3. If you write a function like f (x, y) = x + y the inferred type is int * int -> int. If you changed the language to make operators methods and ints objects, the inferred type would be < + : 'a -> 'b; .. > * 'a -> 'b. Having such a complicated type for such a simple function would probably not be desirable.
    4. Paying the cost of polymorphic dispatch every time an arithmetic operation is used would be bad for performance.

    Also note that in many mainstream languages that support operator overloading, operators tend to be implemented as non-virtual (and thus non-polymorphic) methods or functions as well. Presumably for the performance reason I mentioned above. Having polymorphic operators is rather uncommon.

    PS: In the context of functional languages the term “polymorphism” is most often used to refer to “parametric polymorphism” (what OO languages sometimes call “generics”), while in OO languages it is most often used to refer to “subtype polymorphism”. This answer assumes that you were using the latter meaning of the word since you explicitly mentioned object orientation and since the former meaning doesn’t really make sense in this context.

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

Sidebar

Related Questions

Since Android has different size of layout, the number of rows can be shown
Since each thread has its own stack, its private data can be put on
Since REST is stateless, each request that comes in has no knowledge of the
Since I have no errors I don't know if this is the right place
how can I manage to define a Set in OCaml that can contains element
Since you can take integral values as template parameters and perform arithmetic on them,
Since the retina display, suddenly this piece of drawing code seems to not work
since last post, did all the changes suggested but this problem still haunts me.
Since I started writing this question, I think I figured out the answers to
since my Linksys router doesn't assign a fixed local IP to the computers (PC

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.