Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New transformer: len() #2127

Open
leogr opened this issue Oct 22, 2024 · 1 comment · May be fixed by #2131
Open

New transformer: len() #2127

leogr opened this issue Oct 22, 2024 · 1 comment · May be fixed by #2131
Labels
kind/feature New feature or request
Milestone

Comments

@leogr
Copy link
Member

leogr commented Oct 22, 2024

Motivation

While discussing the intersect operator with @jasondellaluce, we realized there's no easy way to check for an empty list or, more generally, to know a list length.

It would be beneficial when one needs to create an exception, for example:
len(class.somelist) > 0 and not class.somelist intersect (allowlist)

(n.b. not class.somelist intersect (allowlist) is true when class.somelist is an empty list)

Furthermore, there may be compelling use cases where knowing the length of a list or a string is useful.

Feature

Develop a len() transformer that accepts a sizable type (e.g., LIST, CHARBUF, BYTEBUF) as input and returns its length as an integer.

Alternatives

No actual alternatives have been considered yet.

Additional context

This is a very rough proposal, which may need some discussion. Feedback is welcome.

@leogr leogr added the kind/feature New feature or request label Oct 22, 2024
@LucaGuerra LucaGuerra linked a pull request Oct 23, 2024 that will close this issue
@FedeDP
Copy link
Contributor

FedeDP commented Oct 23, 2024

/milestone 0.19.0

@poiana poiana added this to the 0.19.0 milestone Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants