On 09/07/2010 12:44 AM, bearophile wrote:
Andrej Mitrovic:
I'm sorry, but what does q{..} mean?
q{} is just a different syntax to write "" or ``
It's a controversial feature. q{} isn't recognized by editors as a string, so
they colour the syntax it contains normally as code, and not as a string. So
it's a bit useful if you want to give a string to a higher order function like
map, instead of a delegate, and you want to keep the visual illusion of a
delegate:
map!q{a * a}([1, 2, 3])
The problem comes straight from its purpose: is that it doesn't look like a
string, so its true nature is a bit hidden; and this may cause some troubles.
Another possible problem was discussed when the q{} syntax was introduced. It's
not a clean syntax, it's a hack from the point of view of parsing/lexing too.
It's handy, but it may cause troubles too. I am getting used to it, but it's a
untidy hack and it will keep being nothing more than a hack. And sometimes
hacks later come back and bite your bum.
Bye,
bearophile
It's not the same. Try q{\n}.
It's lexed like code.