01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity
MIT License
2.7k stars 67 forks source link

foreach not supported? #162

Open oguz-ismail opened 7 months ago

oguz-ismail commented 7 months ago

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?

wader commented 7 months ago

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

oguz-ismail commented 7 months ago

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

01mf02 commented 6 months ago

@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.

pkoppstein commented 6 months ago

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