From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id CA75519A0A06 for ; Tue, 15 Sep 2015 14:02:33 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 16B59B5D886 for ; Tue, 15 Sep 2015 14:24:52 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 9EAFC97A820 for ; Tue, 15 Sep 2015 14:24:53 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id D9F92952439 for ; Tue, 15 Sep 2015 14:24:51 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0CC59120673; Tue, 15 Sep 2015 14:24:50 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 49CEE1205FD for ; Tue, 15 Sep 2015 14:24:47 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=frM9c2ve8WW/Ug3ypnWCoKuF7hU=; b=I3e/RGkpGsTENVVsHS XyA6/NclhlVcQ70vSI5Lk8kW4kaaat5MwQd+ktjolcWpi8t8Ff8ZVFPkTo4mndGL WYQ8rG/VSLu/QLuJmaS298itP7z+K4nHPX2oaJ/rf1ymSLVqumQcm+2FTilP9NkY deUug/d61T5aIHJpstpI0Xgc0= Received: by filter0621p1mdw1.sendgrid.net with SMTP id filter0621p1mdw1.18780.55F7AB9B10 2015-09-15 05:24:43.540863285 +0000 UTC Received: from herokuapp.com (ec2-54-224-60-230.compute-1.amazonaws.com [54.224.60.230]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id H4dVPHKgQ3anXAZEbi4NyQ Tue, 15 Sep 2015 05:24:43.467 +0000 (UTC) Date: Tue, 15 Sep 2015 05:24:43 +0000 From: hanmac@gmx.de To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45422 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10594 X-Redmine-Issue-Author: findchris X-Redmine-Sender: Hanmac X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7ORas8varlfjt7PDNRogEKbMzLHH/cuIN1ng K0frwn+DStDOr10DN82WDeYOQa11C/7Xetr1m+IqKx8kwKQpRQb0lz3x1uC2tWd+GafwbkDWC0kqK3 FBwtbzR0Ws1Z0f/G7//esKXunBFlMlc+o4A4 X-ML-Name: ruby-core X-Mail-Count: 70810 Subject: [ruby-core:70810] [Ruby trunk - Feature #10594] Comparable#clamp X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10594 has been updated by Hans Mackowiak. Motohiro KOSAKI wrote: > I really dislike using Comparable for this method because clamp is NOT kind of compare. If it is Numeric's method, I'm OK. hm imo its better in Comparable than in Numeric because it does work for non Numeric objects too, like for String thats why its better central in Comparable than in Numeric. ---------------------------------------- Feature #10594: Comparable#clamp https://bugs.ruby-lang.org/issues/10594#change-54192 * Author: Chris Johnson * Status: Open * Priority: Normal * Assignee: ---------------------------------------- This is basically a re-opening of the feature request of issue#4573 (https://bugs.ruby-lang.org/issues/4574), which was closed due a naming debate. It seems the standard naming for restricting a number to a specified range is indeed 'clamp'. (1)(2)(3) As such, can we use Yusuke Endoh's original patch with the naming adjustments? If so, I can provide accordingly. Cheers. (1) http://www.rubydoc.info/github/epitron/epitools/Numeric:clamp (2) http://stackoverflow.com/questions/12020787/is-there-a-limit-clamp-function-in-ruby (3) https://developer.gnome.org/glib/stable/glib-Standard-Macros.html#CLAMP:CAPS ---Files-------------------------------- num_clamp.c (427 Bytes) comparable-clamp.diff (2.52 KB) -- https://bugs.ruby-lang.org/