形式
Plain text
投稿日時
2020-03-23 10:07
公開期間
無期限
  1. % Any copyright is dedicated to the Public Domain.
  2. % http://creativecommons.org/publicdomain/zero/1.0/
  3. %
  4. % Released by Transnat Games for testing purposes.
  5. %
  6. % Adding additional modes to a predicate with a clause that can have no
  7. % solutions when using a disjunction on an input argument silences the warning
  8. % about the disjunct having no solutions.
  9. :- module bad.
  10. %=============================================================================%
  11. :- interface.
  12. %=============================================================================%
  13. :- type x --->
  14. a ;
  15. b ;
  16. c.
  17. :- type y --->
  18. ok ;
  19. error(string).
  20. :- pred res(x, y).
  21. :- mode res(out, in) is det.
  22. % This second mode silences the "disjunct has no solutions" warning.
  23. :- mode res(in, out) is det.
  24. %=============================================================================%
  25. :- implementation.
  26. %=============================================================================%
  27. :- use_module exception.
  28. res(a, ok).
  29. % This arm of the disjunction on the second argument should emit a warning about having no solutions,
  30. % at least for the first mode.
  31. res(b, _) :-
  32. exception.throw(exception.software_error("ERROR")).
  33. res(c, error("c")).
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト