[m-dev.] for review: new browser parameters

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Fri Oct 27 19:40:34 AEDT 2000


Zoltan Somogyi writes:
> On 27-Oct-2000, Mark Anthony BROWN <dougl at cs.mu.OZ.AU> wrote:
> > Hmm, it might be used to hold more than preferences in future.  For example,
> > it could store subterms selected by the user, for use in later interactive
> > queries.
> > 
> > How about browser_persistent_state?
> 
> That is fine.
> 
> > +			dirs	:: list(dir),	% The list of directories to
> > +						% take, starting from the root,
> > +						% to reach the current subterm.
> 
> The type "dir" seems misnamed: it should be named something like "path name
> component".
> 

Throughout the browser design there is an analogy between subterms
and Unix subdirectories.  Hence the commands "ls", "cd", and path
expressions such as "/2/3/1".  I don't know whose idea this was, but
it's been with the browser since I can remember.  We could change this,
of course, but it should be done separately from the changes to the
browser state.

The relative diff for the name change is below (it's pretty boring).
I've committed it now.

Cheers,
Mark.

--- log.old	Fri Oct 27 18:25:57 2000
+++ log	Fri Oct 27 18:25:51 2000
@@ -19,10 +19,10 @@
 	New module which defines the key browser data structures.  The
 	`browser_state' previously used by browse.m has been split into
 	two parts: the transient state (browser_info) and the persistent
-	state (browser_state).  The persistent state is created when the
-	browser is first called, and is saved between calls to the browser,
-	whereas a new transient state is created each time the browser is
-	called, and lasts for the duration of the call.
+	state (browser_persistent_state).  The persistent state is created
+	when the browser is first called, and is saved between calls to the
+	browser, whereas a new transient state is created each time the
+	browser is called, and lasts for the duration of the call.
 
 	The persistent state contains settings for each possible combination
 	of format and caller type.
--- browser/browse.m.old	Fri Oct 27 18:21:58 2000
+++ browser/browse.m	Fri Oct 27 18:24:07 2000
@@ -27,35 +27,38 @@
 	% the default format for the `browse' caller type will be used.
 	%
 :- pred browse__browse(T, io__input_stream, io__output_stream,
-			browser_state, browser_state, io__state, io__state).
+			browser_persistent_state, browser_persistent_state,
+			io__state, io__state).
 :- mode browse__browse(in, in, in, in, out, di, uo) is det.
 
 	% As above, except that the supplied format will override the default.
 	%
 :- pred browse__browse_format(T, io__input_stream, io__output_stream,
-			portray_format, browser_state, browser_state,
-			io__state, io__state).
+			portray_format, browser_persistent_state,
+			browser_persistent_state, io__state, io__state).
 :- mode browse__browse_format(in, in, in, in, in, out, di, uo) is det.
 
 	% The browser interface for the external debugger.  The caller type
 	% will be `browse', and the default format will be used.
 	%
 :- pred browse__browse_external(T, io__input_stream, io__output_stream,
-			browser_state, browser_state, io__state, io__state).
+			browser_persistent_state, browser_persistent_state,
+			io__state, io__state).
 :- mode browse__browse_external(in, in, in, in, out, di, uo) is det.
 
 	% The non-interactive term browser.  The caller type should be either
 	% `print' or `print_all'.  The default portray format for that
 	% caller type is used.
 	%
-:- pred browse__print(T, io__output_stream, browse_caller_type, browser_state,
-			io__state, io__state).
+:- pred browse__print(T, io__output_stream, browse_caller_type,
+			browser_persistent_state, io__state, io__state).
 :- mode browse__print(in, in, in, in, di, uo) is det.
 
 	% As above, except that the supplied format will override the default.
 	%
 :- pred browse__print_format(T, io__output_stream, browse_caller_type,
-			portray_format, browser_state, io__state, io__state).
+			portray_format, browser_persistent_state,
+			io__state, io__state).
 :- mode browse__print_format(in, in, in, in, in, di, uo) is det.
 
 	% Estimate the total term size, in characters,
@@ -132,7 +135,8 @@
 	browse__print_common(Term, OutputStream, Caller, yes(Format), State).
 
 :- pred browse__print_common(T, io__output_stream, browse_caller_type,
-		maybe(portray_format), browser_state, io__state, io__state).
+		maybe(portray_format), browser_persistent_state,
+		io__state, io__state).
 :- mode browse__print_common(in, in, in, in, in, di, uo) is det.
 
 browse__print_common(Term, OutputStream, Caller, MaybeFormat, State) -->
@@ -174,8 +178,8 @@
 		no, State0, State).
 
 :- pred browse_common(debugger, T, io__input_stream, io__output_stream,
-		maybe(portray_format), browser_state, browser_state,
-		io__state, io__state).
+		maybe(portray_format), browser_persistent_state,
+		browser_persistent_state, io__state, io__state).
 :- mode browse_common(in, in, in, in, in, in, out, di, uo) is det.
 
 browse_common(Debugger, Object, InputStream, OutputStream, MaybeFormat,
--- browser/browser_info.m.old	Fri Oct 27 18:22:10 2000
+++ browser/browser_info.m	Fri Oct 27 18:24:21 2000
@@ -29,7 +29,7 @@
 						% Format specified as
 						% an option to the mdb
 						% command.
-			state	:: browser_state
+			state	:: browser_persistent_state
 						% Persistent settings.
 		).
 
@@ -75,7 +75,7 @@
 	% Initialise a new browser_info.  The optional portray_format
 	% overrides the default format.
 	%
-:- pred browser_info__init(T, maybe(portray_format), browser_state,
+:- pred browser_info__init(T, maybe(portray_format), browser_persistent_state,
 		browser_info).
 :- mode browser_info__init(in, in, in, out) is det.
 
@@ -98,27 +98,28 @@
 	% This state must be saved by the caller of the browse module
 	% between calls.
 	%
-:- type browser_state.
+:- type browser_persistent_state.
 
 	% Initialize the persistent browser state with default values.
 	%
-:- pred browser_info__init_state(browser_state).
-:- mode browser_info__init_state(out) is det.
+:- pred browser_info__init_persistent_state(browser_persistent_state).
+:- mode browser_info__init_persistent_state(out) is det.
 
 	% Update a setting in the browser state.  The first six arguments
 	% indicate the presence of the `set' options -P, -B, -A, -f, -p,
 	% and -v, in that order.
 	%
 :- pred browser_info__set_param(bool::in, bool::in, bool::in, bool::in,
-		bool::in, bool::in, setting::in, browser_state::in,
-		browser_state::out) is det.
+		bool::in, bool::in, setting::in, browser_persistent_state::in,
+		browser_persistent_state::out) is det.
 
 %---------------------------------------------------------------------------%
 
 :- implementation.
 :- import_module require.
 
-:- pragma export(browser_info__init_state(out), "ML_BROWSE_init_state").
+:- pragma export(browser_info__init_persistent_state(out),
+		"ML_BROWSE_init_persistent_state").
 
 	%
 	% The following exported predicates are a convenient way to
@@ -126,8 +127,8 @@
 	%
 
 :- pred set_param_depth(bool::in, bool::in, bool::in, bool::in, bool::in,
-		bool::in, int::in, browser_state::in, browser_state::out)
-		is det.
+		bool::in, int::in, browser_persistent_state::in,
+		browser_persistent_state::out) is det.
 :- pragma export(set_param_depth(in, in, in, in, in, in, in, in, out),
 		"ML_BROWSE_set_param_depth").
 
@@ -135,8 +136,8 @@
 	browser_info__set_param(P, B, A, F, Pr, V, depth(Depth)).
 
 :- pred set_param_size(bool::in, bool::in, bool::in, bool::in, bool::in,
-		bool::in, int::in, browser_state::in, browser_state::out)
-		is det.
+		bool::in, int::in, browser_persistent_state::in,
+		browser_persistent_state::out) is det.
 :- pragma export(set_param_size(in, in, in, in, in, in, in, in, out),
 		"ML_BROWSE_set_param_size").
 
@@ -144,8 +145,8 @@
 	browser_info__set_param(P, B, A, F, Pr, V, size(Size)).
 
 :- pred set_param_width(bool::in, bool::in, bool::in, bool::in, bool::in,
-		bool::in, int::in, browser_state::in, browser_state::out)
-		is det.
+		bool::in, int::in, browser_persistent_state::in,
+		browser_persistent_state::out) is det.
 :- pragma export(set_param_width(in, in, in, in, in, in, in, in, out),
 		"ML_BROWSE_set_param_width").
 
@@ -153,8 +154,8 @@
 	browser_info__set_param(P, B, A, F, Pr, V, width(Width)).
 
 :- pred set_param_lines(bool::in, bool::in, bool::in, bool::in, bool::in,
-		bool::in, int::in, browser_state::in, browser_state::out)
-		is det.
+		bool::in, int::in, browser_persistent_state::in,
+		browser_persistent_state::out) is det.
 :- pragma export(set_param_lines(in, in, in, in, in, in, in, in, out),
 		"ML_BROWSE_set_param_lines").
 
@@ -162,7 +163,8 @@
 	browser_info__set_param(P, B, A, F, Pr, V, lines(Lines)).
 
 :- pred set_param_format(bool::in, bool::in, bool::in, portray_format::in,
-		browser_state::in, browser_state::out) is det.
+		browser_persistent_state::in, browser_persistent_state::out)
+		is det.
 :- pragma export(set_param_format(in, in, in, in, in, out),
 		"ML_BROWSE_set_param_format").
 
@@ -198,8 +200,8 @@
 
 %---------------------------------------------------------------------------%
 
-:- type browser_state
-	--->	browser_state(
+:- type browser_persistent_state
+	--->	browser_persistent_state(
 			print_params		:: caller_params,
 			browse_params		:: caller_params,
 			print_all_params	:: caller_params
@@ -231,7 +233,8 @@
 	%		less than about 5 since otherwise very little of the
 	%		term will be shown.
 	%
-browser_info__init_state(browser_state(Print, Browse, PrintAll)) :-
+browser_info__init_persistent_state(State) :-
+	State = browser_persistent_state(Print, Browse, PrintAll),
 	caller_type_print_defaults(Print),
 	caller_type_browse_defaults(Browse),
 	caller_type_print_all_defaults(PrintAll).
@@ -273,7 +276,7 @@
 	maybe_set_param(B, F, Pr, V, Setting, State0 ^ browse_params, BParams),
 	maybe_set_param(A, F, Pr, V, Setting, State0 ^ print_all_params,
 			AParams),
-	State = browser_state(PParams, BParams, AParams).
+	State = browser_persistent_state(PParams, BParams, AParams).
 
 :- pred default_all_yes(bool, bool, bool, bool, bool, bool).
 :- mode default_all_yes(in, in, in, out, out, out) is det.
@@ -328,7 +331,8 @@
 maybe_set_param_2(yes, width(W), Params, Params ^ width := W).
 maybe_set_param_2(yes, lines(L), Params, Params ^ lines := L).
 
-:- pred get_caller_params(browser_state, browse_caller_type, caller_params).
+:- pred get_caller_params(browser_persistent_state, browse_caller_type,
+		caller_params).
 :- mode get_caller_params(in, in, out) is det.
 
 get_caller_params(State, print, State ^ print_params).
@@ -344,10 +348,11 @@
 
 %---------------------------------------------------------------------------%
 
-:- pred browser_state_type(type_info).
-:- mode browser_state_type(out) is det.
-:- pragma export(browser_state_type(out), "ML_BROWSE_browser_state_type").
+:- pred browser_persistent_state_type(type_info).
+:- mode browser_persistent_state_type(out) is det.
+:- pragma export(browser_persistent_state_type(out),
+		"ML_BROWSE_browser_persistent_state_type").
 
-browser_state_type(type_of(State)) :-
-	browser_info__init_state(State).
+browser_persistent_state_type(type_of(State)) :-
+	browser_info__init_persistent_state(State).
 
--- browser/declarative_user.m.old	Fri Oct 27 18:22:23 2000
+++ browser/declarative_user.m	Fri Oct 27 18:24:37 2000
@@ -53,11 +53,11 @@
 	--->	user(
 			instr	:: io__input_stream,
 			outstr	:: io__output_stream,
-			browser	:: browser_state
+			browser	:: browser_persistent_state
 		).
 
 user_state_init(InStr, OutStr, User) :-
-	browser_info__init_state(Browser),
+	browser_info__init_persistent_state(Browser),
 	User = user(InStr, OutStr, Browser).
 
 %-----------------------------------------------------------------------------%
--- trace/mercury_trace_browse.c.old	Fri Oct 27 18:22:47 2000
+++ trace/mercury_trace_browse.c	Fri Oct 27 18:25:14 2000
@@ -40,8 +40,8 @@
 
 #include <stdio.h>
 
-static	MR_Word		MR_trace_browser_state;
-static	MR_TypeInfo	MR_trace_browser_state_type;
+static	MR_Word		MR_trace_browser_persistent_state;
+static	MR_TypeInfo	MR_trace_browser_persistent_state_type;
 
 static	void		MR_trace_browse_ensure_init(void);
 
@@ -69,19 +69,20 @@
 			ML_BROWSE_browse_format(type_info, value,
 				(MR_Word) &mdb_in, (MR_Word) &mdb_out,
 				(MR_Word) format,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_browse(type_info, value,
 				(MR_Word) &mdb_in, (MR_Word) &mdb_out,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
-	MR_trace_browser_state = MR_make_permanent(MR_trace_browser_state,
-			MR_trace_browser_state_type);
+	MR_trace_browser_persistent_state =
+			MR_make_permanent(MR_trace_browser_persistent_state,
+				MR_trace_browser_persistent_state_type);
 }
 
 /*
@@ -103,10 +104,12 @@
 		ML_BROWSE_browse_external(type_info, value,
 			(MR_Word) &MR_debugger_socket_in, 
 			(MR_Word) &MR_debugger_socket_out,
-			MR_trace_browser_state, &MR_trace_browser_state);
+			MR_trace_browser_persistent_state,
+			&MR_trace_browser_persistent_state);
 	);
-	MR_trace_browser_state = MR_make_permanent(MR_trace_browser_state,
-				MR_trace_browser_state_type);
+	MR_trace_browser_persistent_state =
+			MR_make_permanent(MR_trace_browser_persistent_state,
+				MR_trace_browser_persistent_state_type);
 }
 
 #endif
@@ -125,13 +128,14 @@
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_print_format(type_info, value,
 				(MR_Word) &mdb_out, (MR_Word) caller,
-				(MR_Word) format, MR_trace_browser_state);
+				(MR_Word) format,
+				MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_print(type_info, value,
 				(MR_Word) &mdb_out, (MR_Word) caller,
-				MR_trace_browser_state);
+				MR_trace_browser_persistent_state);
 		);
 	}
 }
@@ -151,8 +155,8 @@
 	{
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_set_param_format(print, browse, print_all,
-				new_format, MR_trace_browser_state,
-				&MR_trace_browser_state);
+				new_format, MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
 	else if (streq(param, "depth") && MR_trace_is_number(value, &depth))
@@ -160,8 +164,8 @@
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_set_param_depth(print, browse, print_all,
 				flat, pretty, verbose, depth,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
 	else if (streq(param, "size") && MR_trace_is_number(value, &size))
@@ -169,8 +173,8 @@
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_set_param_size(print, browse, print_all,
 				flat, pretty, verbose, size,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
 	else if (streq(param, "width") && MR_trace_is_number(value, &width))
@@ -178,8 +182,8 @@
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_set_param_width(print, browse, print_all,
 				flat, pretty, verbose, width,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
 	else if (streq(param, "lines") && MR_trace_is_number(value, &lines))
@@ -187,8 +191,8 @@
 		MR_TRACE_CALL_MERCURY(
 			ML_BROWSE_set_param_lines(print, browse, print_all,
 				flat, pretty, verbose, lines,
-				MR_trace_browser_state,
-				&MR_trace_browser_state);
+				MR_trace_browser_persistent_state,
+				&MR_trace_browser_persistent_state);
 		);
 	}
 	else
@@ -196,8 +200,9 @@
 		return FALSE;
 	}
 
-	MR_trace_browser_state = MR_make_permanent(MR_trace_browser_state,
-				MR_trace_browser_state_type);
+	MR_trace_browser_persistent_state =
+			MR_make_permanent(MR_trace_browser_persistent_state,
+				MR_trace_browser_persistent_state_type);
 	return TRUE;
 }
 
@@ -225,22 +230,24 @@
 {
 	static	bool	done = FALSE;
 	MR_Word		typeinfo_type_word;
-	MR_Word		MR_trace_browser_state_type_word;
+	MR_Word		MR_trace_browser_persistent_state_type_word;
 
 	if (! done) {
 		MR_TRACE_CALL_MERCURY(
 			ML_get_type_info_for_type_info(&typeinfo_type_word);
-			ML_BROWSE_browser_state_type(
-				&MR_trace_browser_state_type_word);
-			ML_BROWSE_init_state(&MR_trace_browser_state);
+			ML_BROWSE_browser_persistent_state_type(
+				&MR_trace_browser_persistent_state_type_word);
+			ML_BROWSE_init_persistent_state(
+				&MR_trace_browser_persistent_state);
 		);
 
-		MR_trace_browser_state_type = (MR_TypeInfo) MR_make_permanent(
-					MR_trace_browser_state_type_word,
-					(MR_TypeInfo) typeinfo_type_word);
-		MR_trace_browser_state = MR_make_permanent(
-					MR_trace_browser_state,
-					MR_trace_browser_state_type);
+		MR_trace_browser_persistent_state_type =
+			(MR_TypeInfo) MR_make_permanent(
+				MR_trace_browser_persistent_state_type_word,
+				(MR_TypeInfo) typeinfo_type_word);
+		MR_trace_browser_persistent_state = MR_make_permanent(
+				MR_trace_browser_persistent_state,
+				MR_trace_browser_persistent_state_type);
 		done = TRUE;
 	}
 }
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list