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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:29:10+00:00 2026-05-11T06:29:10+00:00

I am attempting to learn OCaml by using compiled code instead of the top-level;

  • 0

I am attempting to learn OCaml by using compiled code instead of the top-level; however, much of the sample code online seems to appeal to the latter.

I would like to create a new Foo within a method of an object per below. This code does not compile, citing a syntax error with the doFooProc definition.

class bar = object (self)  method doFooProc = (new Foo 'test')#process end;;  class foo (param1:string)= object (self)  method process = Printf.printf '%s\n' 'Processing!'  initializer Printf.printf 'Initializing with param = %s\n' param1 end;; 

Additionally, the ‘let’ syntax don’t seem to be friendly within class definitions. Why is that?

class bar = object (self)  method doFooProc =    let xxx = (new Foo 'test');   xxx#process end;;  class foo (param1:string)= object (self)  method process = Printf.printf '%s\n' 'Processing!'  initializer Printf.printf 'Initializing with param = %s\n' param1 end;; 

How do I go about creating a new object of class foo in the doFooProc method and call the instantiated foo’s process command?

  • 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. 2026-05-11T06:29:11+00:00Added an answer on May 11, 2026 at 6:29 am

    You’re mostly correct, but are either confusing syntax with the module system, or thinking of other languages. Take my considerations and you should be good!

    I would like to create a new Foo within a method of an object per below. This code does not compile, citing a syntax error with the doFooProc definition.

    Lowercase ‘foo’ for objects, modules are uppercase. Also, you must put the definition of foo above the object that calls it. You should get an Unbound class foo if this happens.

    class bar = object (self)  method doFooProc = (new foo 'test')#process end;; 

    Additionally, the ‘let’ syntax don’t seem to be friendly within class definitions. Why is that?

    Because you don’t have a matching in, instead you have a semi-colon. Then it will work. Also, you can remove those extra parens, but it doesn’t matter.

    class bar = object (self)  method doFooProc =    let xxx = (new Foo 'test') in   xxx#process end;; 

    If, say, a method in foo instantiated a bar as well, is there any way to escape the problem that arises with ordering the class definitions within the source file?

    Yes. It’s just like writing mutually recursive functions and modules, you connect them with the and keyword.

    class bar =   object (self)     method doFooProc = (new foo 'test')#process   end  and foo (param1:string) =    object (self)     method process = Printf.printf '%s\n' 'Processing!'     initializer Printf.printf 'Initializing with param = %s\n' param1   end 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I'm with you marc: I'd love to see an extensible… May 11, 2026 at 2:40 pm
  • added an answer I don't believe there is. But what would you do… May 11, 2026 at 2:40 pm
  • added an answer Check out NodeXL. It's free (on CodePlex) - with source.… May 11, 2026 at 2:40 pm

Related Questions

I am attempting to learn oCaml and am having an issue as to why
I'm attempting to learn a little more about handling sockets and network connections in
I am trying to set myself up on a mac to learn Ruby on
Update: We are still using XP at work and I got my solution working,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.