caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list]Warning 20: this argument will not be used by the function.
@ 2011-08-30 11:27 AUGER Cedric
  2011-08-30 22:31 ` John Carr
  0 siblings, 1 reply; 4+ messages in thread
From: AUGER Cedric @ 2011-08-30 11:27 UTC (permalink / raw)
  To: caml-list

Hi all,
while playing with coq and extraction I did the following:

"
Fixpoint narity (n: nat) : Set :=
match n with
|  O  => nat
| S n => nat -> (narity n)
end.

Definition sum_aux : nat -> forall n, narity n :=
fix sum acc n :=
match n as n0 return narity n0 with
|  O  => acc
| S n => fun m => sum (m+acc) n
end.

Definition sum := sum_aux O.

Eval compute in sum 3 14 67 21.

Recursive Extraction sum.
"

I do not want to comment if this is or not meaningfull, but adapting
the code to caml ints (not doing so will do the same thing, but ints
are easier to play with), I got:

        Objective Caml version 3.12.0

# type __ = Obj.t
  ;;
type __ = Obj.t
# let rec sum_aux acc n = if n <= 0
  then Obj.magic acc
  else Obj.magic (fun m -> sum_aux (m+acc) (n-1));;
val sum_aux : int -> int -> 'a = <fun>
# let sum = sum_aux 0;;
val sum : int -> 'a = <fun>
# print_int (sum 3 14 67 21);;
Warning 20: this argument will not be used by the function.
Warning 20: this argument will not be used by the function.
Warning 20: this argument will not be used by the function.
102- : unit = ()

The result is correct, but the warning is quite unexpected!
(Changing the values of the arguments will of course change the result)

It is not important or armfull, but quite funny.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-31  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30 11:27 [Caml-list]Warning 20: this argument will not be used by the function AUGER Cedric
2011-08-30 22:31 ` John Carr
2011-08-30 23:40   ` Philippe Wang
2011-08-31  7:12     ` Esther Baruk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).