Advertisement
C4Cypher

No boxing for c types.

Aug 9th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.45 KB | None | 0 0
  1.  
  2.  
  3. :- module test.
  4.  
  5. :- interface.
  6.  
  7. :- import_module io.
  8.  
  9. :- pred main(io::di, io::uo) is det.
  10.  
  11. :- type foo ---> foo(int).
  12.  
  13. :- pred is_five(foo::in) is semidet.
  14.  
  15. :- implementation.
  16.  
  17. :- pragma foreign_proc("C", is_five(Foo::in),
  18.     [promise_pure, will_not_call_mercury],
  19. "
  20.     SUCCESS_INDICATOR = (Foo == 5);
  21. ").
  22.  
  23. main(!IO) :-
  24.     Foo = foo(5),
  25.     ( is_five(Foo) ->
  26.         print("Foo is five\n", !IO)
  27.     ;
  28.         print("Foo is not five\n", !IO)
  29.     ).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement