Anonymous | Login | Signup for a new account | 2019-02-22 22:31 CET | ![]() |
Main | My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
0007907 | OCaml | middle end (typedtree to clambda) | public | 2019-02-02 18:44 | 2019-02-05 11:04 | ||||||
Reporter | drup | ||||||||||
Assigned To | |||||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||||
Status | new | Resolution | open | ||||||||
Platform | OS | OS Version | |||||||||
Product Version | |||||||||||
Target Version | Fixed in Version | ||||||||||
Summary | 0007907: Specialization vs Indirections | ||||||||||
Description | Several people proposed to have functors that would easily introduce infix operators based on given primitives. That scheme is also used in the monomorphic library (https://github.com/kit-ty-kate/ocaml-monomorphic [^]) and a few others. We already know that specialization of primitives and abstraction don't play particularly well together (https://caml.inria.fr/mantis/view.php?id=7440 [^]), but apparently, basic indirections are really bad too: module Make (A : sig type t end) : sig val (=) : A.t -> A.t -> bool (* external ( = ) : A.t -> A.t -> bool = "%equal" (* SPECIALIZE IF UNCOMENTED *) *) end = struct external ( = ) : A.t -> A.t -> bool = "%equal" end module F = Make(Float) let equal1 (a : float) b = F.(=) a b (* NOT SPECIALIZED *) let equal2 (a : float) b = (=) a b (* SPECIALIZED *) inlining often doesn't help at all with functors, but sometime does in less complex examples. The result is the same with clambda and flambda. | ||||||||||
Tags | No tags attached. | ||||||||||
Attached Files | |||||||||||
![]() |
|
(0019581) stedolan (developer) 2019-02-05 11:04 |
Internally, this issue is the same as 0007440. When an external is exposed by a signature using "val" rather than "external", it is eta-expanded. In other words, the module: module Make (A : sig type t end) : sig val (=) : A.t -> A.t -> bool end = struct external ( = ) : A.t -> A.t -> bool = "%equal" end is internally converted to: module Make (A : sig type t end) : sig val (=) : A.t -> A.t -> bool end = struct external ( eq ) : A.t -> A.t -> bool = "%equal" let (=) a b = eq a b end This turns it into the same pattern as 0007440. |
![]() |
|||
Date Modified | Username | Field | Change |
2019-02-02 18:44 | drup | New Issue | |
2019-02-05 11:04 | stedolan | Note Added: 0019581 |
Copyright © 2000 - 2011 MantisBT Group |