disagreement between spec and Go implementation for macros over maps

33 views
Skip to first unread message

Dan Kortschak

unread,
Mar 14, 2024, 1:18:28 AM3/14/24
to cel-go-...@googlegroups.com
The spec says that none of all, exists, exists_one, filter or map
operate on maps[1].

However, experimentation shows that all do, though instead of binding
the accumulator with the element, they bind with the key (as is
sensible).

Is the cel-go implementation leading the spec or has the spec merely
failed to include an intended capability?

If this is just a failing of the spec, I'd like to send a PR to update.

thanks
Dan

[1]https://github.com/google/cel-spec/blob/master/doc/langdef.md#macros

Tristan Swadell

unread,
Mar 14, 2024, 12:23:41 PM3/14/24
to Dan Kortschak, cel-go-...@googlegroups.com
Hi Dan,

The macros technically work with maps in all languages, but we don't document it as part of the spec due to the impedance mismatch between a map as input and a list as output as well as the fact that iteration of map keys is non-deterministic so the output lists can't really be relied upon to be in any form of sequence (at least for map and filter). 

Ultimately, we'd like to overhaul the macros.

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/15e1216cc510fce39a34232799632bd78ca5539a.camel%40kortschak.io.

Dan Kortschak

unread,
Mar 14, 2024, 4:27:40 PM3/14/24
to cel-go-...@googlegroups.com
On Thu, 2024-03-14 at 09:23 -0700, 'Tristan Swadell' via CEL Go
Discussion Forum wrote:
> Hi Dan,
>
> The macros technically work with maps in all languages, but we don't
> document it as part of the spec due to the impedance mismatch between
> a map as input and a list as output as well as the fact that
> iteration of map keys is non-deterministic so the output lists can't
> really be relied upon to be in any form of sequence (at least for map
> and filter). 
>
> Ultimately, we'd like to overhaul the macros.
>
> -Tristan

Thanks.

What direction would the overhaul likely take? Would it involve
removing the capacity to do this key iteration of maps? (I only just
discovered it because I always believed the spec, but we have had some
need for it, to the extent that the behaviour is mimicked in an
function in our extension lib).

Dan

Tristan Swadell

unread,
Mar 15, 2024, 11:00:58 AM3/15/24
to Dan Kortschak, cel-go-...@googlegroups.com
Hi Dan,

I'd like to support entry-based iteration with key-value pairs for both lists and maps with a new set of comprehension. I'm working through a design now, but it has some rough edges.

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.

Dan Kortschak

unread,
Mar 15, 2024, 4:02:14 PM3/15/24
to cel-go-...@googlegroups.com
On Fri, 2024-03-15 at 08:00 -0700, 'Tristan Swadell' via CEL Go
Discussion Forum wrote:
> Hi Dan,
>
> I'd like to support entry-based iteration with key-value pairs for
> both lists and maps with a new set of comprehension. I'm working
> through a design now, but it has some rough edges.
>
> -Tristan

Thanks.

Is the current behaviour of cel-go expected to remain?

Dan

Tristan Swadell

unread,
Mar 18, 2024, 2:48:25 PM3/18/24
to Dan Kortschak, cel-go-...@googlegroups.com
Hi Dan,

We'll preserve all existing behaviors as well.

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages