Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if two parameters given the same name #2647

Closed
vicuna opened this issue Dec 26, 2000 · 1 comment
Closed

Warn if two parameters given the same name #2647

vicuna opened this issue Dec 26, 2000 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 26, 2000

Original bug ID: 254
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

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 =

val res : int = 20

*)

@vicuna
Copy link
Author

vicuna commented Dec 26, 2000

Comment author: administrator

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 =

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/

@vicuna vicuna closed this as completed Jan 8, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant