[m-rev.] trivial diff: update samples/c_interface/short_example

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Feb 24 00:26:50 AEDT 2005


Estimated hours taken: 0.1
Branches: main, release

samples/c_interface/short_example.m:
	Update this example to use the new foreign language interface.

Julien.

Index: short_example.m
===================================================================
RCS file: /home/mercury1/repository/mercury/samples/c_interface/short_example.m,v
retrieving revision 1.2
diff -u -r1.2 short_example.m
--- short_example.m	10 Sep 1997 11:00:46 -0000	1.2
+++ short_example.m	17 Feb 2005 04:48:24 -0000
@@ -7,16 +7,19 @@
 :- interface.
 :- import_module io.

-:- pred main(io__state::di, io__state::uo) is det.
+:- pred main(io::di, io::uo) is det.

 :- implementation.

-:- pred puts(string::in, io__state::di, io__state::uo) is det.
+:- pred puts(string::in, io::di, io::uo) is det.

-:- pragma c_header_code("#include <stdio.h>").
+:- pragma foreign_decl("C", "#include <stdio.h>").

-:- pragma c_code(non_recursive, puts(S::in, Old_IO::di, New_IO::uo),
-	"puts(S); New_IO = Old_IO; "
-).
+:- pragma foreign_proc("C",
+	puts(S::in, Old_IO::di, New_IO::uo),
+	[promise_pure, will_not_call_mercury],
+"
+	puts(S); New_IO = Old_IO;
+").

-main --> puts("Hello, world\n").
+main(!IO) :- puts("Hello, world\n", !IO).

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list