3 ms·
I hear PHP is a pretty good language nowdays. Now, if we could just optionally drop the $ sign from the beginning of every variable and use them only for string
by kreetx 3y ago
I hear PHP is a pretty good language nowdays. Now, if we could just optionally drop the $ sign from the beginning of every variable and use them only for string templating ;).
- psychoslave 3y agoWhat is so special about string templates that they should be have a different naming scheme? And $ really won't ease your life to search with regexp. Would it only depends on my own preferences, I would use only letters and dash for any identifier in code bases I work with.
- anamexis 3y ago> What is so special about string templates that they should be have a different naming scheme? The fact that you have to distinguish between literal strings and interpolated values
- jdiff 3y agoMaybe string interpolation is just a bad idea. Let strings be strings, use string formatting functions if you want to shove data in them.
- anamexis 3y agoOr maybe they're a very nice convenience, which is why a lot of modern languages are implementing them. String formatting functions use special strings themselves.
- jdiff 3y agoThey do, but very well-defined ones, little placeholders that just concern themselves with formatting. You include the whole variable name and that makes it brittle, now random bits of string data have to be kept in sync with actual code, and makes it a lot more unwieldy to format in a way that isn't the default representation.
- claytongulick 3y agoMaybe take a look at lit-html, postgresjs and some others to get a sense of what's possible with good string templating.
- jdiff 3y agoThose do look quite nice, fairly far away from the nightmares I've dealt with before. They also seem to avoid the problem of just about summoning a whole separate archaic syntax just for jamming variables into a string.