[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is it possible to use @Pipe in a def?
From: |
Valery Ushakov |
Subject: |
Re: Is it possible to use @Pipe in a def? |
Date: |
Tue, 26 Jun 2018 17:40:28 +0300 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
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):
address@hidden 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