-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expose {Int,Int32,Int64,Nativeint}.{min,max} #10389
Copy link
Copy link
Closed
Labels
Description
Stdlib.{min,max} are quite bad performance-wise (even when inlined, they will still call the polymorphic comparison C primitive). In #10251, I proposed to add compiler primitives to allow the optimizer generate better code when those functions are used on simple numerical types, but @xavierleroy's position (#10251 (comment)) is rather that these functions should eventually go away, and one should stop using them.
So, I believe we should:
- Expose specialized versions of the functions in
Int,Int32,Int64,Nativeint. ForChar,UcharandString, it's less obviously useful. ForBool, we already have||and&&, but it could still perhaps be useful (for the sake of uniformity, and also to avoid the short-circuit behavior?). ForFloat, the functions already exist (also with*_numvariants); idem for Zarith`s Q and Z modules. Are people using those functions on non-numerical types? - Mark
Stdlib.{min,max}as being deprecated, in order to help users spot the usually inefficient call sites, and prepare for a possible removal.
Reactions are currently unavailable