[m-rev.] for review: correct type of java list.cons
Ian MacLarty
maclarty at csse.unimelb.edu.au
Tue Aug 24 18:19:24 AEST 2010
Looks fine.
On 8/23/10, Peter Wang <novalazy at gmail.com> wrote:
> For review by Ian.
>
> Branches: main, 10.04
>
> doc/reference_manual.texi:
> library/list.m:
> Correct the type of the Java method `list.cons' so that the
> head element may have a subtype of the list element type.
>
> Add a comment about how to use `list.empty_list'.
>
> diff --git a/doc/reference_manual.texi b/doc/reference_manual.texi
> index 6ad36ef..0c48bd6 100644
> --- a/doc/reference_manual.texi
> +++ b/doc/reference_manual.texi
> @@ -7110,7 +7110,8 @@ boolean list.is_empty(List_1<E> list) // test if
> a list is empty
> E list.det_head(List_1<E> list) // get the head of a list
> List_1<E> list.det_tail(List_1<E> list) // get the tail of a list
> List_1<E> list.empty_list() // create an empty list
> -List_1<E> list.cons(E head, List_1<E> tail) // construct a list with
> +<E, F extends E> List_1<E> list.cons(F head, List_1<E> tail)
> + // construct a list with
> // the given head and tail
> @end example
>
> diff --git a/library/list.m b/library/list.m
> index 99433e5..a112c37 100644
> --- a/library/list.m
> +++ b/library/list.m
> @@ -2867,14 +2867,18 @@ list_to_doc_2([X | Xs]) = Doc :-
> ** the interfaces would expect type_info arguments.
> */
>
> +/*
> +** If you need to specify the type parameter, you must use the qualified
> +** method name, e.g. list.<Integer>empty_list()
> +*/
> public static <E>
> List_1<E> empty_list()
> {
> return new List_1.F_nil_0<E>();
> }
>
> -public static <E>
> -List_1<E> cons(E head, List_1<E> tail)
> +public static <E, F extends E>
> +List_1<E> cons(F head, List_1<E> tail)
> {
> return new List_1.F_cons_2<E>(head, tail);
> }
>
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
>
>
--------------------------------------------------------------------------
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