jaq icon indicating copy to clipboard operation
jaq copied to clipboard

foreach not supported?

Open oguz-ismail opened this issue 1 year ago • 4 comments

See:

oguz@LAPTOP-KKDLALF8:~$ jaq -n 'foreach . as $x (.; .; .)'
Error: Unexpected token while parsing string, expected =, [, and, <=, //, %=, -, %, +, /=, *=, ,, or, *, >=, |=, !=, ==, ", >, ?, |, +=, /, as, <, ), -=
   ╭─[<unknown>:1:22]
   │
 1 │ foreach . as $x (.; .; .)
   │                      ─┬
   │                       ╰── Unexpected token ;
───╯
oguz@LAPTOP-KKDLALF8:~$

Is foreach not supported? What am I doing wrong?

oguz-ismail avatar Feb 27 '24 12:02 oguz-ismail

See end of this section https://github.com/01mf02/jaq?tab=readme-ov-file#folding about foreach/3

wader avatar Feb 27 '24 13:02 wader

@wader Thanks. Why advertise it as a jq clone and waste people's time though?

oguz-ismail avatar Feb 27 '24 13:02 oguz-ismail

@oguz-ismail, I'm sorry to hear that you feel like your time has been wasted. However, jaq implement a sufficiently large set of jq features that I think that it warrants the name "jq clone". Furthermore, most "clones" are not completely identical to their originals, otherwise what would the point of a clone be?

I guess that some heuristics to warn when foreach/3 is used could have partially prevented your problem. However, I do currently not have the resources to implement such heuristics.

01mf02 avatar Mar 11 '24 14:03 01mf02

@01mf02 - Maybe "dialect" would help avoid confusion. That seems to be the compromise in the wikipedia article on jq.

pkoppstein avatar Mar 11 '24 18:03 pkoppstein