digitalmars.D - php strings demo
- Kagamin <spam here.lot> Nov 20 2010
- Kagamin <spam here.lot> Nov 20 2010
- Adam D. Ruppe <destructionator gmail.com> Nov 20 2010
- Kagamin <spam here.lot> Nov 20 2010
- Kagamin <spam here.lot> Nov 20 2010
- Graham Fawcett <fawcett uwindsor.ca> Nov 23 2010
- "Nick Sabalausky" <a a.a> Nov 21 2010
- =?iso-8859-2?B?VG9tZWsgU293afFza2k=?= <just ask.me> Nov 21 2010
- Kagamin <spam here.lot> Nov 21 2010
Content-Type: text/plain
See attachment. It's just a thought. Anyone want this in the language?
---
string sval="ab128#d";
int ival=274;
static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" ==
"asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found)
---
Nov 20 2010
Kagamin Wrote:See attachment. It's just a thought. Anyone want this in the language? --- string sval="ab128#d"; int ival=274; static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" == "asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found) ---
Wrote some unittests today and thought, this feature is useful when one wants easy sql statements (in, e.g. unittests). string typeName="Employee"; int[] ids=executeVector!int("select ID from Objects where type='\{typeName}'");
Nov 20 2010
Kagamin Wrote:Wrote some unittests today and thought, this feature is useful when one wants
Meh, I find the placeholders to be much better (safer too): db.query("select id from objects where type = ?", typeName); I generally feel the same way about all the interpolated strings. Plain old format("%s", var); works for me.
Nov 20 2010
Adam D. Ruppe Wrote:Meh, I find the placeholders to be much better (safer too): db.query("select id from objects where type = ?", typeName);
I use it too, but found it hard to maintain/check ordering and meaning of parameters when you edit the query, add or remove parameters.
Nov 20 2010
Adam D. Ruppe Wrote:Meh, I find the placeholders to be much better (safer too): db.query("select id from objects where type = ?", typeName);
It's also non-trivial to implement such functionality, since MS (and Oracle, afaik) require named parameters.
Nov 20 2010
On Sat, 20 Nov 2010 18:03:34 -0500, Kagamin wrote:Adam D. Ruppe Wrote:Meh, I find the placeholders to be much better (safer too): db.query("select id from objects where type = ?", typeName);
I use it too, but found it hard to maintain/check ordering and meaning of parameters when you edit the query, add or remove parameters.
Isn't that a small price to pay to avoid SQL injection attacks? Best, Graham
Nov 23 2010
"Kagamin" <spam here.lot> wrote in message news:ic9fjp$1nok$1 digitalmars.com...See attachment. It's just a thought. Anyone want this in the language? --- string sval="ab128#d"; int ival=274; static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" == "asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found) ---
Yes. Ruby has that to: var = 42 puts "The value of var plus 7 is #{var + 7}" Actually, that's pretty common in scripting languages. Although, I'd be happy at least with a a good string templating lib. Something like: auto str1 = "The value of $name$ is $val$".render( ["name":"myVar", "val":"17"] ); auto str2 = "Alternate delimiters are ::what::".render( ["what":"useful"], "::" ); That'd be more general anyway.
Nov 21 2010
Dnia 20-11-2010 o 22:46:33 Kagamin <spam here.lot> napisa=B3(a):See attachment. It's just a thought. Anyone want this in the language?=
--- string sval=3D"ab128#d"; int ival=3D274; static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" =3D=3D "asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found) ---
std.conv.text can do this job just fine, bar the "uuu not found" bit. -- = Tomek
Nov 21 2010
Tomek Sowi�ski Wrote:Dnia 20-11-2010 o 22:46:33 Kagamin <spam here.lot> napisa�(a):See attachment. It's just a thought. Anyone want this in the language? --- string sval="ab128#d"; int ival=274; static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" == "asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found) ---
std.conv.text can do this job just fine, bar the "uuu not found" bit.
Ugh... really... -_-
Nov 21 2010









Kagamin <spam here.lot> 