[m-rev.] for review: merge foreign_type pragma on to the main branch
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Oct 24 13:07:07 AEST 2001
On 23-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> +++ foreign.m 23 Oct 2001 14:31:56 -0000
> @@ -496,9 +496,82 @@
> FM = qualified(Module, Name ++ Ending)
> ).
>
> +%-----------------------------------------------------------------------------%
>
> +:- import_module hlds_data.
That should go at the start of the implementation section.
> +:- type export
> + ---> foreign(sym_name)
> + ; mercury((type)).
That type should be documented, and you should use more meaningful names.
> +:- func to_type_string(foreign_language, export_type) = string.
The intended semantics of that function should be explained.
> +to_type_string(c, foreign(Foreign)) =
> + error("to_type_string: c NYI").
> +to_type_string(csharp, foreign(Foreign)) = _ :-
> + Result = sym_name_to_string(ForeignType, ".").
> +to_type_string(managed_cplusplus, foreign(Foreign)) = _ :-
> + Result = sym_name_to_string(ForeignType, ":") ++ " *".
> +to_type_string(il, foreign(Foreign)) = _ :-
> + error("to_type_string: il NYI").
Use sorry/2 rather than error/1.
Shouldn't all these NYI bits be implemented?
> +to_type_string(c, mercury(Type)) = Result :-
> + ( Type = term__functor(term__atom("int"), [], _) ->
> + Result = "MR_Integer"
> + ; Type = term__functor(term__atom("float"), [], _) ->
> + Result = "MR_Float"
> + ; Type = term__functor(term__atom("string"), [], _) ->
> + Result = "MR_String"
> + ; Type = term__functor(term__atom("character"), [], _) ->
> + Result = "MR_Char"
> + ;
> + Result = "MR_Word"
> + ).
Won't that do the wrong thing for type variables with --high-level-code?
Shouldn't the type for those be "MR_Box"?
Ah, thinking about it a bit more, I see that this code is correct.
But a comment or two here, explaining why, might help.
Also, isn't this code the same as export__type_to_type_string?
Why does this code need to be duplicated?
--
Fergus Henderson <fjh at cs.mu.oz.au> | "... it seems to me that 15 years of
The University of Melbourne | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh> | -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
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