Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The ~^ directive of format

0 views
Skip to first unread message

Spiros Bousbouras

unread,
Dec 14, 2009, 7:25:16 PM12/14/09
to
In 22.3.7.4 it says "Finally, the ~^ directive can be used to terminate
the iteration prematurely". When I read that I thought that when ~^ is
encountered the iteration stops. But this isn't how it works. For
example:

* (format nil "~@{- ~a~^ |~} _________________" 'a 'b "ewr")

I thought I would get

"- A _________________"

but I got instead

"- A |- B |- ewr _________________"

So the ~^ stops the iteration only after all items have been processed ;
before that it doesn't have any effect. Have I got it right ? Is there
an omission in the HS ?

--
Is a computer without its case on cyberporn ?

Pascal J. Bourguignon

unread,
Dec 14, 2009, 8:28:37 PM12/14/09
to
Spiros Bousbouras <spi...@gmail.com> writes:

> In 22.3.7.4 it says "Finally, the ~^ directive can be used to terminate
> the iteration prematurely". When I read that I thought that when ~^ is
> encountered the iteration stops. But this isn't how it works. For
> example:
>
> * (format nil "~@{- ~a~^ |~} _________________" 'a 'b "ewr")
>
> I thought I would get
>
> "- A _________________"
>
> but I got instead
>
> "- A |- B |- ewr _________________"
>
> So the ~^ stops the iteration only after all items have been processed ;
> before that it doesn't have any effect. Have I got it right ?

Yes.


> Is there an omission in the HS ?

No. See section "22.3.9.2 Tilde Circumflex: Escape Upward" for details about ~^.


--
__Pascal Bourguignon__

Kenneth Tilton

unread,
Dec 14, 2009, 10:30:03 PM12/14/09
to
Spiros Bousbouras wrote:
> In 22.3.7.4 it says "Finally, the ~^ directive can be used to terminate
> the iteration prematurely". When I read that I thought that when ~^ is
> encountered the iteration stops. But this isn't how it works.

Yeah, it does, but you need the deets in 22.3.9.2 to disambiguate:

"This is an escape construct. /If there are no more arguments remaining
to be processed/, then the immediately enclosing ~{ or ~< construct is
terminated."

Emphasis added. So the prematurity is not terminating processing of the
list, it is the inclusion of other stuff between the tilde braces
(following the tilde circumflex).

kt

0 new messages