Jump to content
  • Advertisement
Sign in to follow this  
MDI

Standard ML question.

This topic is 4696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you include a file, like C's #include preprocessor directive in a .sml file? Suppose I have the following program:
fun p5 =
    print Int.toString 5
In a file. If I try to run this I get an error stating that I cannot use the Int structure before including it. However, all the permutations of open "Int", load "Int" etc. at the beginning of the file produce syntax errors. Does anyone know the answer? I wish to make clear I'm not talking about the interactive top level, where open "Int" works fine, but in an actual .sml file. I'm using the latest release of Moscow ML, if that matters. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I never used Moscow SML, but when I did O'Caml, I think there was something I had to specify when compiling to include a library. You could look into that. Also, go on #sml on irc.freenode.net and see if they can help you out.

Share this post


Link to post
Share on other sites
It is strange that you are having problems since the following works fine for me.

(* p.sml *)

load "Int";

fun p n = print (Int.toString n);
p 10;


[Edit]

Are you trying to run the file through the interpreter or compiler? I think that you have to use open when compiling a file:

(* p.sml *)

open Int;

fun p n = print (Int.toString n);
p 10;

Unfortunately I am far from an expert on sml since I only used it briefly years ago (and that was NJ sml).



[Edited by - Oralloy on October 9, 2005 11:29:54 AM]

Share this post


Link to post
Share on other sites
Thanks, apparently load has to be followed by a semicolon, which isn't required in a .sml file normally.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!