From: Pascal J. Bourguignon on
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> writes:

> On Feb 7, 1:40�am, p...(a)informatimago.com (Pascal J. Bourguignon)
> wrote:
>> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
>> > On Feb 6, 6:34�pm, Morgan <bauer.mor...(a)gmail.com> wrote:
>> >> On Feb 6, 1:22�pm, "webmasterATflymagnetic.com"
>>
>> >> <webmas...(a)flymagnetic.com> wrote:
>> >> > Hi,
>>
>> >> > anyone know how to escape double quotes in a format directive? I'm
>> >> > trying to do the equivalent of the Unix shell command:
>>
>> >> > echo "<a href=\"$1\">$2</a>"
>>
>> >> > but with format:
>>
>> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>>
>> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>>
>> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
>> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
>> >> > the correct answer?
>>
>> >> > Phil
>>
>> >> Hello Phil,
>>
>> >> Use '\'.
>>
>> >> (format t "string with a \" in it")
>>
>> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>>
>> >> hth
>> >> --Morgan
>>
>> > he he, it works. Thanks!
>>
>> I cannot understand why you guessed so.
>> Would you guess that in C, you'd escape double-quotes in strings with a
>> percent? printf("<a href=%"%s%">",url); ???
>>
>> --
>> __Pascal Bourguignon__
>
> I guessed on the understanding that format directives begin with a
> tilde. In C all undefined \char resolve simply to char. Therefore
> ~" (equiv. \") resolves to ". Well That was my logic. :)

Well, not all \char in C resolve to char. That's where you've really
been misled:

In C strings, \n is compiled as a new line:

"First line\nSecond line"

In CL strings, you don't need an escape to insert a new line (or any
other special character such as tab or bells in a string:

"First line
Second Line"


On the other hand, in CL, FORMAT interprets ~% as a newline, ~& as a
newline when needed, and ~newline as various forms of newlines and
spaces depending on the presence of : and @.

I think it is ~% interpreted by FORMAT that made you think that ~ in CL
strings is similar to \ in C string.

However this is erroneous, since ~ is actually inteprreted only by
CL:FORMAT, like % is actually interpreted only by printf (et al.).

--
__Pascal Bourguignon__


From: Pascal J. Bourguignon on
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> writes:

> On Feb 7, 1:40�am, p...(a)informatimago.com (Pascal J. Bourguignon)
> wrote:
>> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
>> > On Feb 6, 6:34�pm, Morgan <bauer.mor...(a)gmail.com> wrote:
>> >> On Feb 6, 1:22�pm, "webmasterATflymagnetic.com"
>>
>> >> <webmas...(a)flymagnetic.com> wrote:
>> >> > Hi,
>>
>> >> > anyone know how to escape double quotes in a format directive? I'm
>> >> > trying to do the equivalent of the Unix shell command:
>>
>> >> > echo "<a href=\"$1\">$2</a>"
>>
>> >> > but with format:
>>
>> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>>
>> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>>
>> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
>> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
>> >> > the correct answer?
>>
>> >> > Phil
>>
>> >> Hello Phil,
>>
>> >> Use '\'.
>>
>> >> (format t "string with a \" in it")
>>
>> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>>
>> >> hth
>> >> --Morgan
>>
>> > he he, it works. Thanks!
>>
>> I cannot understand why you guessed so.
>> Would you guess that in C, you'd escape double-quotes in strings with a
>> percent? printf("<a href=%"%s%">",url); ???
>>
>> --
>> __Pascal Bourguignon__
>
> I guessed on the understanding that format directives begin with a
> tilde. In C all undefined \char resolve simply to char. Therefore
> ~" (equiv. \") resolves to ". Well That was my logic. :)

Well, not all \char in C resolve to char. That's where you've really
been misled:

In C strings, \n is compiled as a new line:

"First line\nSecond line"

In CL strings, you don't need an escape to insert a new line (or any
other special character such as tab or bells in a string:

"First line
Second Line"


On the other hand, in CL, FORMAT interprets ~% as a newline, ~& as a
newline when needed, and ~newline as various forms of newlines and
spaces depending on the presence of : and @.

I think it is ~% interpreted by FORMAT that made you think that ~ in CL
strings is similar to \ in C string.

However this is erroneous, since ~ is actually inteprreted only by
CL:FORMAT, like % is actually interpreted only by printf (et al.).

--
__Pascal Bourguignon__


From: Pascal J. Bourguignon on
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> writes:

> On Feb 7, 1:40�am, p...(a)informatimago.com (Pascal J. Bourguignon)
> wrote:
>> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
>> > On Feb 6, 6:34�pm, Morgan <bauer.mor...(a)gmail.com> wrote:
>> >> On Feb 6, 1:22�pm, "webmasterATflymagnetic.com"
>>
>> >> <webmas...(a)flymagnetic.com> wrote:
>> >> > Hi,
>>
>> >> > anyone know how to escape double quotes in a format directive? I'm
>> >> > trying to do the equivalent of the Unix shell command:
>>
>> >> > echo "<a href=\"$1\">$2</a>"
>>
>> >> > but with format:
>>
>> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>>
>> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>>
>> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
>> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
>> >> > the correct answer?
>>
>> >> > Phil
>>
>> >> Hello Phil,
>>
>> >> Use '\'.
>>
>> >> (format t "string with a \" in it")
>>
>> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>>
>> >> hth
>> >> --Morgan
>>
>> > he he, it works. Thanks!
>>
>> I cannot understand why you guessed so.
>> Would you guess that in C, you'd escape double-quotes in strings with a
>> percent? printf("<a href=%"%s%">",url); ???
>>
>> --
>> __Pascal Bourguignon__
>
> I guessed on the understanding that format directives begin with a
> tilde. In C all undefined \char resolve simply to char. Therefore
> ~" (equiv. \") resolves to ". Well That was my logic. :)

Well, not all \char in C resolve to char. That's where you've really
been misled:

In C strings, \n is compiled as a new line:

"First line\nSecond line"

In CL strings, you don't need an escape to insert a new line (or any
other special character such as tab or bells in a string:

"First line
Second Line"


On the other hand, in CL, FORMAT interprets ~% as a newline, ~& as a
newline when needed, and ~newline as various forms of newlines and
spaces depending on the presence of : and @.

I think it is ~% interpreted by FORMAT that made you think that ~ in CL
strings is similar to \ in C string.

However this is erroneous, since ~ is actually inteprreted only by
CL:FORMAT, like % is actually interpreted only by printf (et al.).

--
__Pascal Bourguignon__


From: Pascal J. Bourguignon on
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> writes:

> On Feb 7, 1:40�am, p...(a)informatimago.com (Pascal J. Bourguignon)
> wrote:
>> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
>> > On Feb 6, 6:34�pm, Morgan <bauer.mor...(a)gmail.com> wrote:
>> >> On Feb 6, 1:22�pm, "webmasterATflymagnetic.com"
>>
>> >> <webmas...(a)flymagnetic.com> wrote:
>> >> > Hi,
>>
>> >> > anyone know how to escape double quotes in a format directive? I'm
>> >> > trying to do the equivalent of the Unix shell command:
>>
>> >> > echo "<a href=\"$1\">$2</a>"
>>
>> >> > but with format:
>>
>> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>>
>> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>>
>> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
>> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
>> >> > the correct answer?
>>
>> >> > Phil
>>
>> >> Hello Phil,
>>
>> >> Use '\'.
>>
>> >> (format t "string with a \" in it")
>>
>> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>>
>> >> hth
>> >> --Morgan
>>
>> > he he, it works. Thanks!
>>
>> I cannot understand why you guessed so.
>> Would you guess that in C, you'd escape double-quotes in strings with a
>> percent? printf("<a href=%"%s%">",url); ???
>>
>> --
>> __Pascal Bourguignon__
>
> I guessed on the understanding that format directives begin with a
> tilde. In C all undefined \char resolve simply to char. Therefore
> ~" (equiv. \") resolves to ". Well That was my logic. :)

Well, not all \char in C resolve to char. That's where you've really
been misled:

In C strings, \n is compiled as a new line:

"First line\nSecond line"

In CL strings, you don't need an escape to insert a new line (or any
other special character such as tab or bells in a string:

"First line
Second Line"


On the other hand, in CL, FORMAT interprets ~% as a newline, ~& as a
newline when needed, and ~newline as various forms of newlines and
spaces depending on the presence of : and @.

I think it is ~% interpreted by FORMAT that made you think that ~ in CL
strings is similar to \ in C string.

However this is erroneous, since ~ is actually inteprreted only by
CL:FORMAT, like % is actually interpreted only by printf (et al.).

--
__Pascal Bourguignon__


From: webmasterATflymagnetic.com on
On Feb 7, 5:56 pm, p...(a)informatimago.com (Pascal J. Bourguignon)
wrote:
> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
> > On Feb 7, 1:40 am, p...(a)informatimago.com (Pascal J. Bourguignon)
> > wrote:
> >> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
> >> > On Feb 6, 6:34 pm, Morgan <bauer.mor...(a)gmail.com> wrote:
> >> >> On Feb 6, 1:22 pm, "webmasterATflymagnetic.com"
>
> >> >> <webmas...(a)flymagnetic.com> wrote:
> >> >> > Hi,
>
> >> >> > anyone know how to escape double quotes in a format directive? I'm
> >> >> > trying to do the equivalent of the Unix shell command:
>
> >> >> > echo "<a href=\"$1\">$2</a>"
>
> >> >> > but with format:
>
> >> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>
> >> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>
> >> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
> >> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
> >> >> > the correct answer?
>
> >> >> > Phil
>
> >> >> Hello Phil,
>
> >> >> Use '\'.
>
> >> >> (format t "string with a \" in it")
>
> >> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>
> >> >> hth
> >> >> --Morgan
>
> >> > he he, it works. Thanks!
>
> >> I cannot understand why you guessed so.
> >> Would you guess that in C, you'd escape double-quotes in strings with a
> >> percent? printf("<a href=%"%s%">",url); ???
>
> >> --
> >> __Pascal Bourguignon__
>
> > I guessed on the understanding that format directives begin with a
> > tilde. In C all undefined \char resolve simply to char. Therefore
> > ~" (equiv. \") resolves to ". Well That was my logic. :)
>
> Well, not all \char in C resolve to char.  That's where you've really
> been misled:
>
> In C strings,  \n is compiled as a new line:
>
>      "First line\nSecond line"
>
> In CL strings, you don't need an escape to insert a new line (or any
> other special character such as tab or bells in a string:
>
>      "First line
> Second Line"
>
> On the other hand, in CL, FORMAT interprets ~% as a newline, ~& as a
> newline when needed, and ~newline as various forms of newlines and
> spaces depending on the presence of : and @.
>
> I think it is ~% interpreted by FORMAT that made you think that ~ in CL
> strings is similar to \ in C string.  

Correct. And I failed, miserably!

>
> However this is erroneous, since ~ is actually inteprreted only by
> CL:FORMAT, like % is actually interpreted only by printf (et al.).
>

Fair point, so it is defined at the functional level, not as part of
the CL language. I am, slowly, trying to get CL included in my
everyday work. I have been looking for a way to hook CL into what I
normally do, and have decided to rewrite one my my Unix shell scripts
in CL. It just hurts to have to think in Lisp! But I can, even from
here, see that the end result is worth it; so I'll just keep plugging
away.

> --
> __Pascal Bourguignon__

Thanks for adding more detail. That's appreciated.

Phil