- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.
- remove special case for Stdlib.Pervasives in printtyp.ml
Function `pp_skip_token` had a comment saying that the queue is never empty
when it is called. However, I came up with a unit test that falsifies that
invariant, see `pp_skip_token.ml`. This prompted to change `pp_skip_token` to
gracefully handle the case when the queue is empty. Before, the invariant was
wrong, but the code still worked correctly because the exception would have
been caught in `advance_left` which used to use `Queue.Empty` exception for
control flow.
This reduces the volume of code in Format and adds clarity by using a
familiar Stack interface. However, this introduces a dependency from
Format to Stack.
This reduces the volume of code in Format and adds clarity by using a
familiar Queue interface. However, this introduces a dependency from
Format to Queue.
Note, `state.pp_queue` was unnecessarily mutable.
Use proper abstract module instead of "%identity" trick.
Add Size.unknown and Size.is_unknown to aid readability
instead of relying on a comment saying that negative
sizes mean unkown sizes.
Calls to raise in Format can accidentally appear in backtraces,
especially when formatting an error message after catching an exception.
By using raise_notrace, the backtrace is no longer clobbered.
- Some addition for formatted pretty-printing.
- Some simplification and precision; in particular, explicitely naming the
standard pretty-printer when we are talking about the standard pretty-printer
In this function, we repeatedly close the open tags.
This function is now called when resetting the pretty-printing engine.
This is a fix: before this commit, tags were never closed when flushing
the pretty-printing engine. Actually, tags were *only* removed from the
the tag stack.
Detail: opened -> open.
This function is broken.
Before you use this function, you might be in either one of these cases:
1. There are no pending open boxes/tags. In this case, flushing the stack has no
effect.
2. You still have some open boxes and/or tags. Thus the function call flushes
them. Now, if you still had some pretty-printing to do afterwards, it makes
no sense to have called this function.
Say for the sake of the argument that only 1 box was left open before the
call:
- Either the rest (e.g. continuation) of your pretty-printing routine assumed
that the box was *closed*: now it is broken.
- Or it *knew* the box was open. The question is now why does it not close it
itself (or pass this obligation to yet another part of the pretty-printing
routine) ?
In either case, this function should *not* be used and thus it should not be
exposed to the user. Let us state here that it breaks the invariants upon which
the Format module has been based.
Before this commit, indentation was identical to outputting blanks.
This is generally true but not always: in some applications you may want to use
'\t' as indentation but not for blanks, ...
The `formatter_out_functions` record is extended with an extra settable field
`out_indent`.
This allows the user to control this aspect of pretty-printing.
The teststuite has been update to reflect this modification.
Previous to this commit the Format API did not allow the user to flush a
formatter's internal queue without also flushing the formatter's output
stream. This was a problem for custom formatters that may have been used
in conjunction with kfprintf or ikfprintf. When the continuation was
called, the formatter's queue of operations may not have been flushed.
The only way that the user could force a queue flush was to call
pp_print_flush, forcing the user to introduce a blocking call before it
was necessary, regardless of other buffer state within the system.
Exposing the internal queue flushing operation solves this problem.
Names may be changed to protect aesthetic sensibilities.
flush_str_formatter rewritten using flush_buffer_formatter.
Consistent naming of pretty-printer formatter as ppf not strange x or o
parameters.
Function ksprintf purposedly defines a new continuation embedding the old
one.
Function asprintf rewritten in a more natural way; spurious pp_flush_queue
deleted in the conitnuation, since it is already done via following
flush_buffer_formatter call.
Indent.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16429 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
This should make the type-checking of formats simpler and more robust:
instead of trying to find a pair as previously, we can now use the
path of the format6 type directly.
A nice side-effect of the change is that the internal definition of
formats (as a pair) is not printed in error messages anymore.
Because format6 is in fact defined in the CamlinternalFormatBasics
submodule of Pervasives, and has an alias at the toplevel of
Pervasives, error messages still expand the definition:
> Error: This expression has type
> ('a, 'b, 'c, 'd, 'd, 'a) format6 =
> ('a, 'b, 'c, 'd, 'd, 'a) CamlinternalFormatBasics.format6
> but an expression was expected of type ...
Passing the option `-short-paths` does avoid this expansion and
returns exactly the same error message as 4.01:
> Error: This expression has type ('a, 'b, 'c, 'd, 'd, 'a) format6
> but an expression was expected of type ...
(To get this error message without -short-paths, one would need to
define format6 directly in Pervasives; but this type is mutually
recursive with several GADT types that we don't want to add in the
Pervasives namespace unqualified. This is why I'll keep the alias
for now.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14868 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
To finish the bootstrap cycle, run:
make library-cross
make promote
make partialclean
make core
make library-cross
make promote-cross
make partialclean
make ocamlc ocamllex ocamltools
make library-cross
make promote
make partialclean
make core
make compare
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14810 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02