-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Repro is with Zed commit 63d6b29. This variation was actually first called out in #4651 (comment).
Here's an example of something that's easy in Python, which might be familiar to our data-centric users due to how Python is often used with Pandas et al.
$ python3
Python 3.11.5 (main, Aug 24 2023, 15:18:16) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> numbers = [4,5,6]
>>> numbers[0]=1
>>> print(numbers)
[1, 5, 6]
Attempting the same using Zed with what I'd think of as the equivalent straightforward syntax:
$ zq -version
Version: v1.10.0-5-g63d6b299
$ echo '{numbers:[4,5,6]}' | zq -z 'numbers[0]:=1' -
illegal left-hand side of assignment
It's been pointed out that it's possible to get there today if the user is familiar with slices & spread:
$ echo '{numbers:[4,5,6]}' | zq -z 'cut numbers:=[1,...numbers[1:]]' -
{numbers:[1,5,6]}
However, given how the simple reference to the element on the left-hand side is common in other languages, it seems like it would be convenient to the user if it worked similarly in Zed.
FWIW, I tried to make use of this syntax in https://github.com/brimdata/challenges/blob/aace23e1ef85b7f411323d776977afc4cfa9935e/ames-shaping/shaper.zed#L3-L23.