“Tim Bates” tim@bates.id.au schrieb im Newsbeitrag
news:20030916231638.GA31636@bates.id.au…
···
On Wed, Sep 17, 2003 at 07:29:04AM +0900, Hal Fulton wrote:
Fulton’s Third Law says that there is an exception to every rule,
except Fulton’s Third Law.
So what your saying is, Fulton’s Third Law has no exception? Does that
not make the Law its own exception? And if it has an exception, does
that not make the second clause paradoxical, or at least wrong?
On Wed, Sep 17, 2003 at 07:29:04AM +0900, Hal Fulton wrote:
Fulton’s Third Law says that there is an exception to every rule,
except Fulton’s Third Law.
So what your saying is, Fulton’s Third Law has no exception? Does that
not make the Law its own exception? And if it has an exception, does
that not make the second clause paradoxical, or at least wrong?
is a lot for the interpreter to handle if one also wants to preserve a
semlance of readability.
Readability is subjective. Besides, good syntax highlighting can really
help in this case And also, interpreters (and the parsers they use for
reading my ruby jumble) don’t really have a problem with readability. We
humans are much more demanding.
print “<user #{“name="” + name + “"”}>”
…
AFAICS, it is grammatically perfectly sound.
…
I agree, it seems like a reasonable construction.
I investigated this a little bit. The relevant code starts at line 4079
in parse.y. I am not familiar enough with the inner workings of parse.y to
see offhand what this code is trying to do, but it was obviously inserted to
specifically catch this situation. This may simply be a limitation in the
way quoting is implemented.
Maybe we should ask Matz…
I think we should. Or we just did.
I wonder if it’s one of those things that is made difficult
by the use of yacc?
AFAIK, it is not. It’s not really the usual construction in a language
since it requires the lexer to have some kind of state to have it
differentiate between a simple ‘}’ and one that resumes a string as in my
example above. flex, which is used in combination with yacc, allows for
start conditions, and that is just what is needed. I’d say it increases
code size, not complexity.
At Wed, 17 Sep 2003 17:42:17 +0900, Yukihiro Matsumoto wrote:
I’ve thought, according to the thread from [ruby-dev:17421],
and [ruby-dev:17549], it’s intentional (but transitional).
It’s not tough to change it, will we do it now?
Please. 1.8.1 should work as it is.
Is it OK without warnings? That is, “#{”""“}” is evaluated
as “” till now, but it will become “""” from now.
Heh – a polite way of saying it’s Nobu’s bug. grin
But seriously, it sure is refreshing to know that matz will see an issue
within a day at the most, and will immediately know and say whether or
not it truly is a bug. Thanks matz (and Nobu too).
I think he deserves a thanks from me too. Especially from me since I
started all this
And just for the record, the piece of code I gave was stripped down to
highlight the problem, rather than to highlight the kind of code I would
write. In many mailinglists/newsgroups this is considered good practice,
but I can see it led to some confusion as to the point of my question. A
hooray for Matz for getting the point immediately
Definitely. And the stripping down probably is good practice, even if
people like me will sometimes miss the point.
As to why, I don’t know. As to whether it is necessary that it be this
way, I don’t know.
I don’t know either. What I do know is that the expression I wrote down
made sense to me, and that the Principle of Least Surprise says that it
then also should to the ruby interpreter, but it did not (forgive me the
blasphemy). I’m curious as to what the problem is rather than interested
in knowing all possible work-arounds. The latter was never the intention
of my initial e-mail (but thanks anyway for the many replies, I can see
now why people exclaim that they love the ruby community I’ll wait for
Matz to show up.
I suppose all such programs have warned during 1.8.0 period.
Well, it’s not only about warnings. This is a transcript of a ruby
session:
irb(main):001:0> print “<user#{” name="" + name + “"”}>\n"
irb(main):002:-1/ mumble
irb(main):003:-1/ jumble
irb(main):004:-1/ /
(irb):1: warning: escaped terminator ‘"’ inside string interpolation
SyntaxError: compile error
(irb):4: unterminated string meets end of file
(irb):4: syntax error
from (irb):4
irb(main):005:0>
There’s the warning about the escaped ‘"’, but also an error since I get
stuck in a regular expression because of the / in . If I put the
print statement in a file and run ruby on it, it joyfully produces this: