Anniepoo / weblog

Web Framework for SWI-Prolog
GNU Lesser General Public License v3.0
40 stars 6 forks source link

Non-deterministic mode for `start_server/1`? #14

Closed wouterbeek closed 9 years ago

wouterbeek commented 10 years ago

About starting the server (predicate start_server/1:

%   nondet because the server might not start

My questions:

Anniepoo commented 10 years ago

yes, should be semidet, though I can't find that code!

wouterbeek commented 10 years ago

It's in demo/weblogdemo:#67:

%%  start_server is nondet
%
%   Starts the weblog demo server.
%   nondet because the server might not start
%
start_server:-
  setting(http:port, Port),
  start_server(Port).

start_server(Port):-
  must_be(between(1000,9999), Port),
  http_server_property(Port, start_time(StartTime)), !,
  print_message(informational, server_running(Port,StartTime)).
start_server(Port):-
  % @tbd for unclear reasons, uncommenting this breaks the Google Maps demo.
  %html_set_options([dialect(xhtml)]),
  http_server(http_dispatch, [port(Port), timeout(3600)]),

  at_halt(stop_server(Port)),

  http_log('Starting weblog demo on port ~w~n', [Port]),
  print_message(informational, server_started(Port)).

I don't think this is semi-deterministic.

PS: I was expecting that it were easy to link to code lines in a commit on Github, but I couldn't figure out how to do it.

Anniepoo commented 10 years ago

Your version's apparently out of date. Latest on my machine has renamed this predicate to start.