--Pd0ReVV5GZGQvF3a Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 31, 2002 at 01:27:57AM +0900, Yukihiro Matsumoto wrote: > In message "Ruby Language Q's" > on 02/07/30, "Justin Johnson" <justinj / mobiusent.com> writes: > |2. I like the idea of named method parameters (ala Smalltalk, Objective-C). > |There was a discussion elsewhere showing something similar using hash > |tables. With a bit of syntactic sugar... :var => 10 could be var: 10 > > I want something more, for example: > > class PC > def initialize(cpu:, os: "Windows", **info) > @cpu = cpu # "cpu" is a mandatory named arg > @os = os # "os" is with the default value > @info = info # symbol=>value hashtable > end > end > PC.new(os: "Linux", cpu: "P-III", clock: "600MHz", hdd: "30G") I'd prefer "=" instead of ":" because passing parameters is a kind of assignment in the scope of the functions body: class PC def initialize(cpu, os="Windows", **info) @cpu = cpu # "cpu" is a mandatory named arg @os = os # "os" is with the default value @info = info # symbol=>value hashtable end end PC.new(os="Linux", cpu="P-III", clock="600MHz", hdd="30G") Although I must admit that this is incompatible to how ruby works currently: def foo(param="bar") param end param="my value" foo() # => "bar" foo("baz") # => "baz" foo(param="qux") # => "qux" param # => "qux" !!! Therefor there certainly is a need for discussion :) -billy -- Meisterbohne Söælinger StraÝÆ 100 Tel: +49-731-399 499-0 eLungen 89077 Ulm Fax: +49-731-399 499-9 --Pd0ReVV5GZGQvF3a Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9RslWfBriNoqItSYRAvJAAJ42YTfcsbWxbN0wVI+qDhpegHNi2wCfaT5M DS2Epa8my88jiryERBsAbzcK -----END PGP SIGNATURE----- --Pd0ReVV5GZGQvF3a--