-
Notifications
You must be signed in to change notification settings - Fork 238
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
Update intro examples #177
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -632,7 +632,7 @@ A CEL expression is parsed and evaluated in the scope of a particular protocol | |
buffer package, which controls name resolution as described above, and a binding | ||
context, which binds identifiers to values, errors, and functions. A given | ||
identifier has different meanings as a function name or as a variable, depending | ||
on the use. For instance in the expression `size(requests) > size`, the first | ||
on the use. For instance in the expression `requests.size() > size`, the first | ||
`size` is a function, and the second is a variable. | ||
|
||
The CEL implementation provides mechanisms for adding bindings of variable names | ||
|
@@ -914,7 +914,7 @@ size of the inputs. | |
cost of `O(P * I)`, and see below. | ||
* Eliminating all of the above and using only default-cost functions, plus | ||
aggregate literals, time and space are limited `O(P * I)`. | ||
A limiting time example is `size(x) + size(x) + ...`. | ||
A limiting time example is `x.size() + x.size() + ...`. | ||
A limiting time and space example is `[x, x, ..., x]`. | ||
|
||
Note that custom function will alter this analysis if they are more expensive | ||
|
@@ -942,31 +942,31 @@ specified by the following overloads: | |
size | ||
</th> | ||
<td> | ||
(string) -> int | ||
string.() -> int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'm okay marking the function-style version as "deprecated", but I don't think it's okay to just remove it. Anyone attempting to implement a compatible CEL implementation will need to provide the function-style versions for the foreseeable future, so it ought to be in the language spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh, now it's a confusing example because we're not listing the full set of overloads. Unfortunately, the other functions with multiple overloads are either:
So consider whether there's a better example to use here, but I'm okay with just the receiver-style size functions if you don't think there's a better alternative. |
||
</td> | ||
<td> | ||
string length | ||
number of unicode codepoints in the string | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(bytes) -> int | ||
bytes.() -> int | ||
</td> | ||
<td> | ||
bytes length | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(list(A)) -> int | ||
list(A).() -> int | ||
</td> | ||
<td> | ||
list size | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(map(A, B)) -> int | ||
map(A, B).() -> int | ||
</td> | ||
<td> | ||
map size | ||
|
@@ -2152,14 +2152,30 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). | |
</td> | ||
</tr> | ||
<tr> | ||
<th rowspan="4"> | ||
<th rowspan="8"> | ||
size | ||
</th> | ||
<td> | ||
string.() -> int | ||
</td> | ||
<td> | ||
number of unicode codepoints in the string | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(string) -> int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark the function-style overload as "deprecated", here and below. (Boy, I wish we had adapted Uniform Function Call Syntax and we wouldn't have had to worry about any of this.) |
||
</td> | ||
<td> | ||
string length | ||
number of unicode codepoints in the string | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
bytes.() -> int | ||
</td> | ||
<td> | ||
bytes length | ||
</td> | ||
</tr> | ||
<tr> | ||
|
@@ -2170,6 +2186,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). | |
bytes length | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
list(A).() -> int | ||
</td> | ||
<td> | ||
list size. Time cost proportional to the length of the list. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(list(A)) -> int | ||
|
@@ -2178,6 +2202,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). | |
list size. Time cost proportional to the length of the list. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
map(A, B).() -> int | ||
</td> | ||
<td> | ||
map size. Time cost proportional to the number of entries. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
(map(A, B)) -> int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the 4 receiver-style size() declarations to the list of standard definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've basically replaced the global existing definitions with the receiver-style ones. That's been the preference internally for quite some time, but I didn't realize this wasn't reflected publicly.