[m-dev.] for review: use readline in browser/

Fergus Henderson fjh at cs.mu.OZ.AU
Fri May 28 00:35:20 AEST 1999


On 27-May-1999, Mark Anthony BROWN <dougl at cs.mu.OZ.AU> wrote:
> browser/browse.m:
> 	[...] change some if-then-elses to switches, which will help
> 	catch errors if a new functor is added to the debugger type.

This is a very good move.  Erwan, please take note ;-)

> browser/browse.m:
> 	Remove the io__input_stream argument to browse__browse/7 and
> 	predicates it calls, since the argument is no longer used.
> 
> browser/interactive_query.m:
> 	Remove the io__input_stream argument to interactive_query__query/6,
> 	and call util__trace_getline instead.
> 
> trace/mercury_trace_browse.c:
> 	Don't pass MR_mdb_in to ML_BROWSE_browse and ML_query.

Hmm.  It seems a bit asymmetrical to be passing the output stream down
but not the input stream, even though you are in fact doing both input
and output.  There's nothing specifically wrong with it, but it just
seems a bit inelegant, which makes me want to look for alternative
solutions.

Now I understand that the input is eventually being done
via readline(), but readline() itself takes a pair of FILE* 
arguments.  So what is happening is that the output stream
used for ordinary output is being passed down as a parameter,
whereas the input stream that readline uses and the output
stream that readline uses for printing the prompt
are being communicated via global variables.

Did you consider the possibility of
	(a) using global variables for both, i.e.
	    making the output stream a global variable too
or	(b) using parameter passing for both, i.e.
	    passing the input and output streams down through
	    util__trace_getline and MR_trace_getline() to readline()
?

I'm happy to leave the final judgement of which of these
three possibilities is the most elegant (and/or least work ;-)
up to you, but I'd like to be sure that you have at least
considered those options.

> browser/interactive_query.m:
>       [...] reorder some
> 	arguments to ml so that the ml options are before the '-o'.

That's really an unrelated change; it might be better to commit
that one separately.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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