[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: #{} and \" don't like each other

Peter

9/16/2003 11:04:00 PM

2 Answers

Hal E. Fulton

9/16/2003 11:10:00 PM

0

Peter wrote:
> I really don''t see the problem with interpreting what I wrote. On
> encountering ''#{'' in a string literal, anything up to the first unbalanced
> ''}'' can be interpreted as any general ruby expression, including ''\"'' in
> string literals within that expression, and after encountering the
> unbalanced ''}'' the reading of the original string is resumed until the
> closing quote. AFAICS, it is grammatically perfectly sound.

I agree, it seems like a reasonable construction.

> 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?

Hal


nobu.nokada

9/17/2003 2:16:00 AM

0

Hi,

At Wed, 17 Sep 2003 08:04:18 +0900,
Peter wrote:
> > As you may have already discovered, the following gives the expected
> > results:
> >
> > print "<user #{"name=" + name + ""}></user>"
>
> It does not since I want quotes around the name...

These work as expected, and are faster.

print "<user name=\"#{name}\"}></user>"
print %{<user name="#{name}"}></user>}

> I really don''t see the problem with interpreting what I wrote. On
> encountering ''#{'' in a string literal, anything up to the first unbalanced
> ''}'' can be interpreted as any general ruby expression, including ''\"'' in
> string literals within that expression, and after encountering the
> unbalanced ''}'' the reading of the original string is resumed until the
> closing quote. AFAICS, it is grammatically perfectly sound.

Yes, it can be interpreted as you expected, and may be in
future version. But it was different till 1.6, so "escaped
terminator" is warned and interpreted as sole terminator, for
backward compatibility.

--
Nobu Nakada