Re: Is it possible to use @Pipe in a def?

Valery Ushakov <[email protected]> Tue, 26 Jun 2018 17:40:28 +0300
Newsgroups gmane.comp.type-setting.lout
Message-ID <[email protected]>
On Tue, Jun 26, 2018 at 08:40:52 +0100, Mark Summerfield wrote:

> However, when I try to make it into a symbol:
> 
> import @BasicSetup
> def @SortedLines right x{
>     lines @Break "sort" @Pipe{x}
> }
> 
> And then use it:
> 
> @ID @SortedLines{
> Gaskell, Elizabeth
> Lawrence, D. H.
> Austen, Jane
> Dickens, Charles
> }
> 
> It just prints the original lines unsorted.
> 
> Is it possible to make such a symbol? Or is there a workaround?

It looks like you can't.  The expert's guide is rather terse, but it
says that (emphasis mine):

  [@FilterIn] contain[s] the actual right or body parameter of the
  symbol, EXACTLY AS IT APPEARS IN THE INPUT FILE.

If you trace lout invocation, you will see that the louti* file for
your nested invocation of @Pipe contains just "x", "exactly as it
appears in the input file".  That x is sorted and read back.  Then
it's evaluated, so you get your original right parameter ("x").

This makes sense in a way.  Naively speaking - to be able to filter
something you need literal text of that something.  By the time the
nested invocation of @Pipe is reached, the "x" of the caller has
already been parsed and its literal text is not available.

-uwe