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
ma fonction n'est pas assez polymorphe #3353
Comments
Comment author: administrator Behavior due to restrictive treatment of type variables in type constraints |
Comment author: administrator On peut aisement contourner le probleme des variables nommees pas assez let (read_string, read_string_in) =
Donc le probleme n'est pas dramatique. Jacques Garrigue |
Comment author: administrator Date: Mon, 10 Jun 2002 05:29:20 +0200 (MET DST) On peut aisement contourner le probleme des variables nommees pas Donc le probleme n'est pas dramatique. Bruno. |
Comment author: @damiendoligez Underscore as a type variable is documented here: The (implicit) binding of type variables in type constraints is not going to change anytime soon, as that would probably break some programs while providing very little improvement. |
Original bug ID: 1156
Reporter: administrator
Status: closed (set by @xavierleroy on 2013-08-31T10:46:03Z)
Resolution: not a bug
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Monitored by: till
Bug description
Objective Caml version 3.04
(Même chose avec la version 3.04+10 (2002-04-18))
#load "unix.cma";;
Soient ces 2 fonctions:
let read_string_bang ?(src=Unix.stdin) s = Unix.read src s 0 (String.length s);;
val read_string_bang : ?src:Unix.file_descr -> string -> int =
let read_string_bang_in ?(src=stdin) s = input src s 0 (String.length s);;
val read_string_bang_in : ?src:in_channel -> string -> int =
Je veux écrire ça:
let (read_string, read_string_in) =
;;
val read_string : ?src:Unix.file_descr -> int -> string =
val read_string_in : ?src:in_channel -> int -> string =
Mais si je précise le type de reader, ça ne va plus:
let (read_string, read_string_in) =
This expression has type ?src:in_channel -> string -> int
but is here used with type ?src:Unix.file_descr -> string -> int
Pourquoi ? (Je connais la règle mu, mais il n'y a pas de let rec ici).
Le problème est que read_string_bang/read_string_bang_in ont en
réalité 2 autres arguments optionnels, et que j'ai le choix entre:
let (read_string, read_string_in) =
;;
mais dans cette forme d'expression, les arguments optionnels ne le
sont plus du tout ?? et:
let (read_string, read_string_in) =
;;
qui ne passe pas.
Noter qu'extraire read en le rendant global dans ce dernier exemple
est accepté par le compilo (!).
Alors, bug or feature ?
Bruno.
The text was updated successfully, but these errors were encountered: