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

wish : methode polymorphe et type contraint #8030

Closed
vicuna opened this issue Feb 25, 2003 · 3 comments · Fixed by #9957
Closed

wish : methode polymorphe et type contraint #8030

vicuna opened this issue Feb 25, 2003 · 3 comments · Fixed by #9957
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 25, 2003

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

Bug description

Full_Name: Laurent Vibert
Version: 3.06
OS:
Submission from: cafe.irisa.fr (131.254.22.19)

Bonjour,

Quand une variable est contrainte, je ne vois aucun moyen de la rendre
polymorphe :

class type o = object end
class ['a] c = object constraint 'a = #o end

class type c2 = object method m : 'a. 'a c end;;
(* This type 'a should be an instance of type #o as 'b = < .. > *)

class type c2 = object method m : 'a. (_ c) as 'a end;;
(* This type has no row variable *)

class type c2 = object method m : 'a. (#o as 'a) c end;;
(* This type #o should be an instance of type #o as 'a = < .. >
The universal variable 'b would escape its scope *)

par contre, ceci marche parfaitement , mais ce n'est pas ce qu'on voulait :
class type c2 = object method m : 'a. (_ #c) as 'a end;;

@vicuna
Copy link
Author

vicuna commented Mar 7, 2003

Comment author: administrator

From: lvibert@irisa.fr

Quand une variable est contrainte, je ne vois aucun moyen de la rendre
polymorphe :

Effectivement, il y avait un bug. C'est maintenant corrige' en CVS.

class type o = object end
class ['a] c = object constraint 'a = #o end
[...]
par contre, ceci marche parfaitement , mais ce n'est pas ce qu'on voulait :
class type c2 = object method m : 'a. (_ #c) as 'a end;;

En fait, si ca marche c'est un peu par hasard: dans cet exemple 'a
n'apparait pas dans l'expansion du type de c, et par consequent on ne
verifie pas qu'il est generalisable.

Si on ecrit plutot
class type ['a] c = object constraint 'a = #o method get : 'a end
alors il faut ecrire
class type c2 = object method m : #o #c end;;
qui signifie exactement la meme chose (la quantification est implicite
dans les types de classes)
A present
class type c2 = object method m : #o c end;;
marche aussi.

Attention, pour des raisons techniques, la notation explicite
class type c2 = object method m : 'a. (#o as 'a) c end
ne marche toujours pas dans ce cas. Je suis a` la recherche d'une
solution, mais ca a l'air assez complique'.

Jacques

@vicuna
Copy link
Author

vicuna commented May 19, 2003

Comment author: administrator

Je crois que c'est maintenant corrige' en CVS.

    Objective Caml version 3.06+33 (2003-05-19)

class type o = object end

class ['a] c = object constraint 'a = #o end;;
class type o = object end
class ['a] c : object constraint 'a = #o end

class type c2 = object method m : 'a. 'a c end;;

class type c2 = object method m : #o c end

class type c2 = object method m : 'a. (_ c) as 'a end;;

This type scheme cannot quantify 'a : it is not a variable.

class type c2 = object method m : 'a. (#o as 'a) c end;;

class type c2 = object method m : #o c end

class type c2 = object method m : #o c end;;

class type c2 = object method m : #o c end

Comme ca a demande' pas mal de changement, merci de verifier que ca ne casse
pas vos programmes.

Jacques

@vicuna
Copy link
Author

vicuna commented May 19, 2003

Comment author: administrator

Fixed by JG (2003-05-19)
Also aliases inside a polymorphic type scheme are now local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant