# 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.

## 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.

Nobody?

##### Share on other sites
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 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;

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 on other sites
Thanks, apparently load has to be followed by a semicolon, which isn't required in a .sml file normally.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 14
• ### Forum Statistics

• Total Topics
632155
• Total Posts
3004477

×