From: Chad Perrin Date: 2011-06-02T01:48:35+09:00 Subject: Re: CORE - Alternative Variable Substitution --ftEhullJWpWg/VHq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 01, 2011 at 10:23:01PM +0900, Peter Hickman wrote: > How about you actually say what you want. The one line example tells > us nothing about the variable substitution mechanism you are expecting >=20 > What constitutes a variable name to be substituted, anything between > the '&' and the next whitespace perhaps? > How would you expect it to handle something line "&this&that&other". > Will it correctly concatenate the values together or will it force > spaces between the substitutions? > How should it escape real &s in the text such as "cat & dog"? > How should it handle missing variables? > How will it handle trailing text such as this in Ruby #{distance}m or > #{year}-#{month}-#{day}? > Will it be expected to handle constants, classes, instance / class > variables and globals? To be fair, I think the answer to these might be "however the existing library handles it," if there is such a thing. The question called for any existing library that offers (as I interpret it) an alternate syntax for variable interpolation in strings; the & example seemed to me to be nothing more than a way to illustrate the possibility of alternate syntaxes in case the question was not clear, and not to illustrate a *specific* syntax that was required. >=20 > Until you tell us what you want no one can help you. Given your one > example it could be possible to create a dozen different libraries > that handle the cases I've given in completely different ways and yet > be consistent for the one case you give >=20 > But more interestingly what is deficient in the current #{} method? It's a lot more typing than (for instance) Perl's use of $ for variable interpolation. I guess some people might consider that a "deficiency". Unless the answer to the posed question is easily discovered with a very simple Google search (I don't think it is) or the person posing the question has an ulterior motive that undermines the honest interest of the question (I have no specific reason to believe so, as far as I'm aware), I think it's a perfectly reasonable question to ask, if for no other reason than curiosity. =2E . . though I suspect the answer is "no, there isn't such a library; would you like to write one?" --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --ftEhullJWpWg/VHq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk3maWYACgkQ9mn/Pj01uKWNpQCg2bdpDXDYl+3RtSCxscLyFZjL O3oAoLOZssfcxp9bhvXZwN/4YaQeqaWP =Sjy9 -----END PGP SIGNATURE----- --ftEhullJWpWg/VHq--