[m-rev.] for review: io.write for streams

Simon Taylor staylr at gmail.com
Tue Dec 19 22:42:36 AEDT 2006


On 19-Dec-2006, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> 
> On Fri, 15 Dec 2006, Simon Taylor wrote:
> 
> >Implement io.write for arbitrary streams.  With type specialization
> >this is only slightly slower than the original.
> >
> >library/stream.string_writer.m:
> >	A module containing predicates for writing to streams
> >	which accept strings.
> 
> Is there a reason that you are putting these predicates in a sub-module of
> stream.m rather than just in stream.m itself?  Also, I'm not crazy about the
> name string_writer, it sounds like a set of predicates for contructing
> strings.  At the moment, I guess my preference would be to just add
> everything to stream.m.

That leads to 8000 line modules like io.m.  If there is a sensible set
of functionality that can be split out, it's better to do it.

I'm open to suggestion on the name, maybe stream.put_string.
 
> >library/stream.m:
> >	Move stream.format to stream.string_writer.m.
> 
> The predicate is_format_call/5 in compiler/format_call.m will also
> need to be updated.

Done.

> >Mmake.common.in:
> >compiler/modules.m:
> >compiler/mlds.m:
> >compiler/mlds_to_c.m:
> >compiler/mlds_to_java.m:
> >compiler/mlds_to_managed.m:
> >compiler/prog_util.m:
> >	Allow sub-modules in the standard library.
> 
> There may also be some code in mdbcomp/prim_data.m that needs updating.

Done.

> >browser/browse.m:
> >tests/hard_coded/stream_format.m:
> >tests/hard_coded/test_injection.m:
> >tests/invalid/string_format_bad.m:
> >tests/invalid/string_format_unknown.m:
> >	Updated for predicates moving between library modules.
> 
> (The NEWS file will also need updating but there's no point doing that
> until the original announcment of stream module is committed.)

All the moved predicates (apart from stream.format) were in the
undocumented interface section.

Simon.


only in patch2:
--- mdbcomp/prim_data.m	24 Nov 2006 03:48:16 -0000	1.15
+++ mdbcomp/prim_data.m	19 Dec 2006 10:08:56 -0000
@@ -212,7 +212,7 @@
     % Returns the sym_name of the module with the given name in the
     % Mercury standard library.
     %
-:- func mercury_std_lib_module_name(string) = sym_name.
+:- func mercury_std_lib_module_name(sym_name) = sym_name.
 
     % Succeeds iff the specified module is one of the builtin modules listed
     % above which may be automatically imported.
@@ -294,7 +294,7 @@
 mercury_profiling_builtin_module = unqualified("profiling_builtin").
 mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
 mercury_par_builtin_module = unqualified("par_builtin").
-mercury_std_lib_module_name(Name) = unqualified(Name).
+mercury_std_lib_module_name(Name) = Name.
 
 any_mercury_builtin_module(Module) :-
     ( Module = mercury_public_builtin_module
only in patch2:
--- compiler/prog_type.m	1 Dec 2006 15:04:17 -0000	1.30
+++ compiler/prog_type.m	19 Dec 2006 10:58:50 -0000
@@ -756,7 +756,7 @@
 
 type_is_io_state(Type) :-
     type_to_ctor_and_args(Type, TypeCtor, []),
-    ModuleName = mercury_std_lib_module_name("io"),
+    ModuleName = mercury_std_lib_module_name(unqualified("io")),
     TypeCtor = type_ctor(qualified(ModuleName, "state"), 0).
 
 type_ctor_is_array(type_ctor(qualified(unqualified("array"), "array"), 1)).
@@ -862,7 +862,7 @@
     Name = qualified(BuiltinModule, "type_ctor_info").
 
 io_state_type = defined_type(Name, [], kind_star) :-
-    Module = mercury_std_lib_module_name("io"),
+    Module = mercury_std_lib_module_name(unqualified("io")),
     Name = qualified(Module, "state").
 
 %-----------------------------------------------------------------------------%
only in patch2:
--- compiler/format_call.m	9 Nov 2006 00:47:24 -0000	1.8
+++ compiler/format_call.m	19 Dec 2006 11:01:03 -0000
@@ -10,10 +10,10 @@
 % Author: zs.
 % 
 % The job of this module is to generate warnings about calls to
-% string.format, io.format and stream.format in which the format string and
-% the supplied lists of values do not agree. The difficult part of this job
-% is actually finding the values of the variables representing the format
-% string and the list of values to be printed.
+% string.format, io.format and stream.string_writer.format in which the format
+% string and the supplied lists of values do not agree. The difficult part of
+% this job is actually finding the values of the variables representing the
+% format string and the list of values to be printed.
 %
 % The general approach is a backwards traversal of the procedure body. During
 % this traversal, we assign an id to every conjunction (considering a cond and
@@ -186,15 +186,15 @@
 
 is_format_call(ModuleName, Name, Args, FormatStringVar, FormattedValuesVar) :-
     Name = "format",
-    ( ModuleName = mercury_std_lib_module_name("string") ->
+    ( ModuleName = mercury_std_lib_module_name(unqualified("string")) ->
         % We have these arguments regardless of whether we call the
         % predicate or function version of string.format.
         Args = [FormatStringVar, FormattedValuesVar, _ResultVar]
-    ; ModuleName = mercury_std_lib_module_name("io") ->
+    ; ModuleName = mercury_std_lib_module_name(unqualified("io")) ->
         ( Args = [FormatStringVar, FormattedValuesVar, _IOIn, _IOOut]
         ; Args = [_Stream, FormatStringVar, FormattedValuesVar, _IOIn, _IOOut]
         )
-    ; ModuleName = mercury_std_lib_module_name("stream") ->
+    ; ModuleName = mercury_std_lib_module_name(unqualified("stream")) ->
         % Since we do this check after polymorphism there will have been
         % a typeclassinfo inserted at the front of the argument list.
         Args = [_TC_InfoForStream, _Stream, FormatStringVar,
@@ -498,7 +498,8 @@
                 ConjMap = conj_map(StringMap, ListMap0, ElementMap0, EqvMap0)
             ;
                 ConsId = cons(SymName, _Arity),
-                StringModule = mercury_std_lib_module_name("list"),
+                StringModule =
+                    mercury_std_lib_module_name(unqualified("list")),
                 SymName = qualified(StringModule, Functor),
                 (
                     Functor = "[|]",
@@ -517,7 +518,8 @@
             ;
                 ConsId = cons(SymName, Arity),
                 Arity = 1,
-                StringModule = mercury_std_lib_module_name("string"),
+                StringModule =
+                    mercury_std_lib_module_name(unqualified("string")),
                 SymName = qualified(StringModule, Functor),
                 (
                     Functor = "f",
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list