Replies: 4 comments
-
I believe - and take this with a grain of salt, because I'm not an expert -
that there's no clean way to get at this (unless you want to mess with
strings). Read the section on 'Program Fragments', noting particularly the
equivalence with word and 'is treated as an indivisible unit'.
This might clarify:
```
; x = { ls | head }
; echo $x
{%pipe {ls} 1 0 {head}}
; echo $x(1)
{%pipe {ls} 1 0 {head}}
```
Here you notice the way es internally rewrites pipes into 'normal' es calls
(where the first thing is executed and each part is another program
fragment), but also that you can't index into a fragment (here it's a
single element list).
…On Thu, 25 Feb 2021 at 18:18, simalaia ***@***.***> wrote:
Is it possible to treat code blocks as structures and manipulate them as
such? I'm poking at implementing something like the multipipe blocks from
dagsh and figured a basic version could be doable with a function that
takes a block and just rewires the pipes.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#30>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAT4YZT5QXYDSDAHLVAID3TAX2VNANCNFSM4YF6WIEQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Ah, in my enthusiasm I read that section and only noted that program fragments are effectively first class and completely ignored the 'indivisible' part... One could maybe do this in a slightly more heavy handed way:
I'll toy around with this and see whether I can come up with anything. Somewhat unrelated, are there any structures in |
Beta Was this translation helpful? Give feedback.
-
While program fragments can't be manipulated in any other way than executing or stringifying them, you have a lot of ways to influence their behavior on execution. You can, for example, redefine those As for the structures, there are only flat lists, ...and closures, so you can make an arbitrarily complex structures you need. 😉
|
Beta Was this translation helpful? Give feedback.
-
Oh, good point! I was inventing complicated schemes involving building structures on |
Beta Was this translation helpful? Give feedback.
-
Is it possible to treat code blocks as structures and manipulate them as such? I'm poking at implementing something like the multipipe blocks from dagsh and figured a basic version could be doable with a function that takes a block and just rewires the pipes.
Beta Was this translation helpful? Give feedback.
All reactions