[m-dev.] For review: new extras package - curses binding

Robert Ernst Johann JESCHOFNIK rejj at students.cs.mu.oz.au
Mon Jan 31 14:06:49 AEDT 2000


On Sat, 15 Jan 2000, Fergus Henderson wrote:

> On 14-Jan-2000, Robert Ernst Johann JESCHOFNIK <rejj at cat.cs.mu.OZ.AU> wrote:
> >  		A Mercury library package containing support for
> >  		complex and imaginary numbers.
> >  
> > +curses		A Mercury library providing a (partial) binding to 
> > +		curses.
> 
> What's "curses"?
> You should not assume that the user will know what curses is.

Fixed, I put a (brief) description in the top-level README (ie, in the
extras/ dir).


> > +:- module mcurses:basics.
> 
> Please don't use `:', use `__' instead.

fixed.

> > +  % Initilise curses.
> 
> Spelling error.

fixed.


> > This is used by curse.m, and should not be called by the
> > +  % programmer.
> > +:- pred init(io__state, io__state).
> > +:- mode init(di, uo) is det.
> ...
> > +:- pragma c_code(init(IO0::di, IO::uo), "
> > +{
> > +	WINDOW *w;
> > +	w = initscr();
> > +	noecho();
> > +	cbreak();
> > +	keypad(w, TRUE);
> > +	IO = IO0;
> > +}
> > +").
> 
> Hmm, the fact that this turns of echoing, etc.
> should be documented somewhere...

Done - I put the comment with the init predicate that is intended for use
by the programmer though, not on this one.


> I suggest you change the example to use DCG notation:
> 
>   % main -->
>   %	for(0, 5, (pred(Num::in, di, uo) is det -->
>   %     	io__print(Num)
>   % 	)).
> 
> > +		for(Min+1, Max, Pred, Acc1, Acc)

done

> 
> s/Min+1/Min + 1/
> 

 and done

> > Index: curses/sample/Mmakefile
> > ===================================================================
> > RCS file: Mmakefile
> > diff -N Mmakefile
> > --- /dev/null	Thu Mar  4 04:20:11 1999
> > +++ Mmakefile	Fri Jan 14 15:30:03 2000
> > @@ -0,0 +1,16 @@
> > +# Specify location of the mcurses library
> > +MCURSES_DIR = ..
> > +
> > +# Tell mmake to use the mcurses library
> > +VPATH = 	$(MCURSES_DIR):$(MMAKE_VPATH)
> > +MCFLAGS = 	-I$(MCURSES_DIR) $(EXTRA_MCFLAGS)
> > +MLFLAGS = 	-R$(MCURSES_DIR) $(EXTRA_MLFLAGS) \
> > +		-L$(MCURSES_DIR)
> > +# Note that you have to tell the linker to use the mcurses library
> > +# AND the ncurses library (which mcurses is an interface for)
> > +MLLIBS =	-lmcurses -lncurses $(EXTRA_MLLIBS)
> > +C2INITFLAGS =	$(MCURSES_DIR)/mcurses.init
> 
> This could be significantly simplified now;
> see the "Libraries" chapter of the Mercury User's Guide.

I do not see how - this is not the Mmakefile for building the library,
that is for the sample that *uses* the library.

>From the documentation:
--
Using libraries

To use a library, you need to set the Mmake variables `VPATH', `MCFLAGS',
`MLFLAGS', `MLLIBS', and `C2INITARGS' to specify the name and location of
the library or libraries
that you wish to use. If you are using `--intermodule-optimization', you
may also need to set `MGNUCFLAGS' if the library uses the C interface. For
example, if you want to
link in the libraries `mypackage' and `myotherlib', which were built in
the directories `/some/directory/mypackage' and
`/some/directory/myotherlib' respectively,
you could use the following settings: 

# Specify the location of the `mypackage' and `myotherlib' directories
MYPACKAGE_DIR = /some/directory/mypackage
MYOTHERLIB_DIR = /some/directory/myotherlib

# The following stuff tells Mmake to use the two libraries
VPATH = $(MYPACKAGE_DIR):$(MYOTHERLIB_DIR):$(MMAKE_VPATH)
MCFLAGS = -I$(MYPACKAGE_DIR) -I$(MYOTHERLIB_DIR) $(EXTRA_MCFLAGS)
MLFLAGS = -R$(MYPACKAGE_DIR) -R$(MYOTHERLIB_DIR) $(EXTRA_MLFLAGS) \
          -L$(MYPACKAGE_DIR) -L$(MYOTHERLIB_DIR)
MLLIBS = -lmypackage -lmyotherlib $(EXTRA_MLLIBS)
C2INITARGS = $(MYPACKAGE_DIR)/mypackage.init \
             $(MYOTHERLIB_DIR)/myotherlib.init

# This line may be needed if `--intermodule-optimization'
# is in `MCFLAGS'. `-I' options should be added for any other
# directories containing header files that the libraries require.
MGNUCFLAGS = -I$(MYPACKAGE_DIR) -I$(MYOTHERLIB_DIR) $(EXTRA_MGNUCFLAGS)
--

and that is what I did.


Rob

--------------------------------------------------------------------------
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