[m-rev.] for review: allow negation of accumulating options

Simon Taylor stayl at cs.mu.OZ.AU
Mon Jan 14 15:07:59 AEDT 2002



Estimated hours taken: 0.25
Branches: main

NEWS:
library/getopt.m:
	Implement negation of accumulating options,
	which empties the accumulated list of strings.


Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.236
diff -u -u -r1.236 NEWS
--- NEWS	12 Jan 2002 09:08:04 -0000	1.236
+++ NEWS	14 Jan 2002 03:55:59 -0000
@@ -82,7 +82,7 @@
   return `[|]' rather than `.' for lists, and calls to std_util__construct
   which construct lists may need to be updated.
 
-* We've added a func version of error/1, called func_error/1, to require.m.
+* We've added a function version of error/1, called func_error/1, to require.m.
 
 * ops.m now defines a typeclass which can be used to define operator
   precedence tables for use by parser.m and term_io.m. See
@@ -143,6 +143,10 @@
 
 * We've added a version of `getopt__process_options' which returns
   the option arguments.
+
+* `getopt__process_options' has been modified to allow negation of
+  accumulating options. Negating an accumulating option empties
+  the accumulated list of strings.
 
 * We've added some functions to the term_io module to return printable
   representations of term components as strings.
Index: library/getopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/getopt.m,v
retrieving revision 1.25
diff -u -u -r1.25 getopt.m
--- library/getopt.m	13 Nov 2001 13:53:32 -0000	1.25
+++ library/getopt.m	14 Jan 2002 03:50:45 -0000
@@ -63,11 +63,13 @@
 % It is an error to use a "special" option for which there is no
 % handler, or for which the handler fails.
 %
-% Single-character boolean (i.e. bool or bool_special) or maybe_*
-% options can be negated by following them with another `-', e.g. `-x-'
-% will negate the `-x' option.  Long boolean or maybe_* options can be
-% negated by preceding them with `--no-', e.g. `--no-foo' will negate
-% the `--foo' option.
+% Boolean (i.e. bool or bool_special), maybe_int, maybe_string
+% and accumulating options can be negated. Negating an accumulating
+% option empties the accumulated list of strings.
+% Single-character options can be negated by following them
+% with another `-', e.g. `-x-' will negate the `-x' option.
+% Long options can be negated by preceding them with `--no-',
+% e.g. `--no-foo' will negate the `--foo' option.
 
 :- module getopt.
 :- interface.
@@ -606,6 +608,10 @@
 			Result = ok(OptionTable)
 		; OptionData = maybe_string(_) ->
 			map__set(OptionTable0, Flag, maybe_string(no),
+					OptionTable),
+			Result = ok(OptionTable)
+		; OptionData = accumulating(_) ->
+			map__set(OptionTable0, Flag, accumulating([]),
 					OptionTable),
 			Result = ok(OptionTable)
 		; OptionData = bool_special ->
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list