[m-rev.] diff/for review: step 1 of fixing eliminating type_info/1's argument
Mark Brown
mark at cs.mu.OZ.AU
Tue Sep 20 13:00:35 AEST 2005
On 19-Sep-2005, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> This is step 1 of eliminating the arguments of the type_ctor_info, type_info,
> base_typeclass_info and typeclass_info type constructors. This step doesn't
> delete those arity-1 type constructors yet; that will be done in step 2.
> This delay due to bootstrapping issues: installed compilers still generate
> references to those type constructors. However, after this change, compilers
> will instead generate references to arity-0 versions of those types named
> zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and
> zero_typeclass_info.
>
> library/private_builtin.m:
> Add the new type constructors.
You should add a comment near these new definitions explaining that the types
of type_infos, etc, are duplicated temporarily for bootstrapping purposes.
> Index: compiler/polymorphism.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
> retrieving revision 1.274
> diff -u -b -r1.274 polymorphism.m
> --- compiler/polymorphism.m 13 Sep 2005 04:56:10 -0000 1.274
> +++ compiler/polymorphism.m 18 Sep 2005 08:54:56 -0000
> @@ -3203,24 +3200,36 @@
> % Note: we no longer store meaningful information in the argument
> % of typeclass_info/1.
> PrivateBuiltin = mercury_private_builtin_module,
> - TypeclassInfoTypeName = qualified(PrivateBuiltin, "typeclass_info"),
> - DictionaryType = defined(TypeclassInfoTypeName, [void_type], star).
> + TypeclassInfoTypeName =
> + qualified(PrivateBuiltin, "zero_typeclass_info"),
> + DictionaryType = defined(TypeclassInfoTypeName, [], star).
This predicate can probably be deleted and replaced with a constant
function in type_util.m (but it's not that important to do it now).
> polymorphism__type_is_type_info_or_ctor_type(TypeInfoType) :-
> type_to_ctor_and_args(TypeInfoType,
> - qualified(mercury_private_builtin_module, TypeName) - 1,
> - [_Type]),
> - ( TypeName = "type_info" ; TypeName = "type_ctor_info" ).
> + qualified(mercury_private_builtin_module, TypeName) - Arity,
> + Args),
> + ( TypeName = "type_info", Args = [_], Arity = 1
> + ; TypeName = "type_ctor_info", Args = [_], Arity = 1
> + ; TypeName = "zero_type_info", Args = [], Arity = 0
> + ; TypeName = "zero_type_ctor_info", Args = [], Arity = 0
> + ).
The (redundant) test of Args here can be ommitted to make the code a bit
shorter and slightly more efficient.
>
> polymorphism__build_type_info_type(Type, TypeInfoType) :-
> + % XXX TypeInfoType = type_ctor_info_type.
> ( type_has_variable_arity_ctor(Type, _, _) ->
> % We cannot use a plain type_ctor_info because we need to
> % record the arity.
Could you expand on that XXX comment, please?
Other than that, this looks fine.
Cheers,
Mark.
--------------------------------------------------------------------------
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