expr icon indicating copy to clipboard operation
expr copied to clipboard

Allow methods to be used in pipes `foo | some.Method(42) | foo.Bar()`

Open KyleSanderson opened this issue 7 months ago • 1 comments

map(filter(Imp.GetTorrents(nil), .Name contains `The.Simpsons`), .Hash) | Imp.RemoveTags(`yamz`)","error":"unexpected token Operator(\".\") (1:78)\n | map(filter(Imp.GetTorrents(nil), .Name contains `The.Clam`), .Hash) | Imp.RemoveTags(`yamz`)
{"level":"trace","program":"test-program","query":"map(filter(Imp.GetTorrents(nil), .Name contains `The.Clam`), .Hash) | Imp.RemoveTags(`yamz`)","error":"unexpected token Operator(\".\") (1:78)\n | map(filter(Imp.GetTorrents(nil), .Name contains `The.Simpsons`), .Hash) | Imp.RemoveTags(`yamz`)\n | .............................................................................^","time":1747350352,"message":"expr completed: <nil>"}

vs

let egg = Imp.RemoveTags; map(filter(Imp.GetTorrents(nil), .Name contains `The.Clam`), .Hash) | egg(`yamz`)
{"level":"trace","program":"test-program","query":"let egg = Imp.RemoveTags; map(filter(Imp.GetTorrents(nil), .Name contains `The.Clam`), .Hash) | egg(`yamz`)","time":1747350503,"message":"expr completed: <nil>"}

KyleSanderson avatar May 15 '25 23:05 KyleSanderson

This is a kind of decision on language design. Now for pipes only function allowed. Methods are not.

  1. Should we allow methods to be used in pipes?
  2. What is the use case?
  3. Does it make expressions more readable?

antonmedv avatar Sep 18 '25 12:09 antonmedv