From: Philipp Meier Date: 2002-07-31T02:13:38+09:00 Subject: Re: Ruby Language Q's --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" 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 =3D> 10 could be var: = 10 >=20 > I want something more, for example: >=20 > class PC > def initialize(cpu:, os: "Windows", **info) > @cpu =3D cpu # "cpu" is a mandatory named arg > @os =3D os # "os" is with the default value > @info =3D info # symbol=3D>value hashtable > end > end > PC.new(os: "Linux", cpu: "P-III", clock: "600MHz", hdd: "30G") I'd prefer "=3D" instead of ":" because passing parameters is a kind of assignment in the scope of the functions body: class PC def initialize(cpu, os=3D"Windows", **info) @cpu =3D cpu # "cpu" is a mandatory named arg @os =3D os # "os" is with the default value @info =3D info # symbol=3D>value hashtable end end PC.new(os=3D"Linux", cpu=3D"P-III", clock=3D"600MHz", hdd=3D"30G") Although I must admit that this is incompatible to how ruby works currently: def foo(param=3D"bar") param end param=3D"my value" foo() # =3D> "bar" foo("baz") # =3D> "baz" foo(param=3D"qux") # =3D> "qux" param # =3D> "qux" !!! Therefor there certainly is a need for discussion :) -billy --=20 Meisterbohne S=F6flinger Stra=DFe 100 Tel: +49-731-399 499-0 eL=F6sungen 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 DS2Epa8my88jiryERBsAbzc= =FuZK -----END PGP SIGNATURE----- --Pd0ReVV5GZGQvF3a--