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 32D4B17DD993 for ; Sun, 18 Jan 2015 17:11:28 +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 38DFAB5D876 for ; Sun, 18 Jan 2015 17:09:46 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 146C797A827 for ; Sun, 18 Jan 2015 17:09:48 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JWI-1OM_LQLj for ; Sun, 18 Jan 2015 17:09:47 +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 A050297A826 for ; Sun, 18 Jan 2015 17:09:47 +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 2DAEF95241A for ; Sun, 18 Jan 2015 17:09:45 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A452B120439; Sun, 18 Jan 2015 17:09:41 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 68FEC120421 for ; Sun, 18 Jan 2015 17:09:38 +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=hgYKse3NlBYS530uer5oFUPvtpk=; b=fGhgSuhMJ7S0verTsd dxNjGXx7Eq8icNmdPS4dDPKfTRz+eaH2ljxXLI1dO5cPA1dXelhLPnbvsyHEwNNQ FsZvbcLVm9d2GpL32ARAwi9vWLGHe+bxVyvuUNamkIWoTEyyXRCTvk+yxg2r2SaG mAobZBW0QkiTS3Q/tCFR8evY0= Received: by filter0064p1mdw1.sendgrid.net with SMTP id filter0064p1mdw1.17744.54BB6A3D4 2015-01-18 08:09:33.433853434 +0000 UTC Received: from herokuapp.com (ec2-54-198-146-237.compute-1.amazonaws.com [54.198.146.237]) by ismtpd-020 (SG) with ESMTP id 14afc16ffbd.4ee8.184196 for ; Sun, 18 Jan 2015 08:09:33 +0000 (UTC) Date: Sun, 18 Jan 2015 08:09:33 +0000 From: sertackaya@msn.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Redmine-MailingListIntegration-Message-Ids: 42099 X-Redmine-Project: common-ruby X-Redmine-Issue-Id: 7747 X-Redmine-Issue-Author: jballanc X-Redmine-Sender: sertac X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: OOF Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6g4ijCZE3IMwXMW25xqfImEeya4y/p/kyG40 +qZ+toCHb4RmK1OZ7YiXnLn7uD4MOeL4+a3O6FCoq7SQ8nStab1qXkWLirZ77C80wwIMxpWhVX1EAd cW32nm8pvA84aZzb5mLn+M6oSkoCkk7vM9zu X-ML-Name: ruby-core X-Mail-Count: 67674 Subject: [ruby-core:67674] [CommonRuby - Feature #7747] Expanded API for Binding semantics 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 #7747 has been updated by sertac kaya. =C3=9Cr=C3=BCn=C3=BCm=C3=BCz=C3=BCn yan etkisi yoktur. http://v-pillsbuyut.com/v-pills-yan-etkileri.html ---------------------------------------- Feature #7747: Expanded API for Binding semantics https://bugs.ruby-lang.org/issues/7747#change-51090 * Author: Joshua Ballanco * Status: Open * Priority: Normal * Assignee:=20 ---------------------------------------- =3Dbegin Currently, the only way to create a new instance of Binding is to get a cop= y of the current scope's binding, or ask some other object for its binding.= In either case, the binding object returned always has semantics identical= to the original binding. In other words, a binding object used with eval i= s capable of (not necessarily an exhaustive list): * redefining methods on the binding target * defining new methods on the binding target * getting/setting instance variables * getting/creating new constants This feature proposal would introduce a new mechanism for creating a bindin= g and adjusting its relationship with the source binding. For example, if y= ou have a class (({Foo})) defined like so: class Foo def say puts "hello!" end end Then you would be able to create a new binding that ((*won't*)) propagate n= ew definitions to the parent binding like so: new_binding =3D Binding.new(Foo) new_binding.propagate =3D false new_binding.eval("def shout; puts 'HI!'; end") =20=20=20=20 Foo.new.say #=3D> "hello!" Foo.new.shout #=3D> No Method Error new_binding.eval("Foo.new.say") #=3D> "hello" new_binding.eval("Foo.new.shout") #=3D> "HI!" If, additionally, we introduce a way to merge or combine bindings, then thi= s API could actually be used to implement refinements in pure Ruby like so = (note I am also assuming that (({Binding#eval})) gains the ability to take = a block): class Module def refine(klass, &block) @refined_bindings ||=3D {} refinement_binding =3D Binding.new(klass) refinement_binding.propagate =3D false refinement_binding.shadow =3D true refinement_binding.eval &block (@refined_bindings[self.name] ||=3D []) << refinement_binding end =20=20=20=20 def using(mod) @refined_bindings[mod].each { |refinement| self.binding.merge(refin= ement) } end end Following is the preliminary list of additional APIs I am tentatively propo= sing (though I expect this to change with additional discussion): * (({Binding.new(an_object)})) - creates a new Binding object that "inherit= s" the binding of the argument; essentially equivalent to (({an_object.send= (:binding).dup})) * (({Binding#propagate}))/(({Binding#propagate=3D})) - boolean; determines = whether new method, class, or Constant defs are propagated into the "parent= " binding's scope * (({Binding#shadow}))/(({Binding#shadow=3D})) - boolean; sets whether or n= ot new values for existing methods/constants/variables can be set * (({Binding#freeze})) - causes the Binding to capture all existing methods= /constants/variables in scope at call time, and "disconnect" from the paren= t binding, so that any updates to definitions or values are no longer refle= cted into the "child" binding * (({Binding#merge(other_binding)})) - combines the method/constant/variabl= e bindings in (({other_binding})) with the receiver; effectively shadows th= e "parent" of (({other_binding})) within the receiver binding =3Dend --=20 https://bugs.ruby-lang.org/