Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000254OCamlOCaml generalpublic2000-12-26 20:272001-01-08 11:54
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000254: Warn if two parameters given the same name
DescriptionIn the following example, I used the name x twice. I understand why
the first x is hidden, but I still don't like the behaviour :-)

A warning whenever you hide a parameter name or variable would be appropriate,
since I don't see the use of it at all.

/mattias

mattias.waldau@abc.se


let f x x = x

let res = f 10 20


(*

# val f : 'a -> 'b -> 'b = <fun>
val res : int = 20
#

*)
 


TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002196)
administrator (administrator)
2000-12-26 21:45

> In the following example, I used the name x twice. I understand why
> the first x is hidden, but I still don't like the behaviour :-)
>
> A warning whenever you hide a parameter name or variable would be appropriate,
> since I don't see the use of it at all.
>
> /mattias
>
> mattias.waldau@abc.se
>
>
> let f x x = x
>
> let res = f 10 20
>
>
> (*
>
> # val f : 'a -> 'b -> 'b = <fun>
> val res : int = 20
> #
>
> *)

Many users like to reuse the same names when there is no ambiguity,
and for sake of program clarity. For instance:

let apply_succ n f = let n = n + 1 in f n;;

or

let rec loop i accu j lim =
  if j >= lim then accu else
  let i = i + j
  and j = j + 1
  and accu = i :: j :: accu in
  loop i accu j lim;;

I do not see clearly how to accept this kind of programming style,
while warning for your (fun x -> fun x -> ...). Have you some idea ?

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ [^]



- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker