Comments (3)
After discussion with the language council, there are some difficulties with using null
:
- There is the above ambiguity when setting a
Value
field, wherenull
is a legitimate value. - It will cause confusion with the type checker. The type checker already special-cases
null
for unset wrapper type fields, but it is difficult to generalize this.
A separate value of checker-time type dyn
solves these problems. Note #149 which will let us add a new standard name without invalidating existing programs.
We do not intend to use unset
when reading fields, as we'd like to preserve deep select expressions without needing to do a has()
check at each level.
Open questions:
- What is the runtime behavior of
unset
? Things get quite complicated if it's not a value in the language. E.g. it would be hard to explain why we can doMyProto{f: test ? value : unset}
but notMyProto{f: [value, unset][test ? 0 : 1]}
. - In particular, what is the runtime type of
unset
?
from cel-spec.
There is some ambiguity for Value fields: does MyProto { value_field: null } mean unset or set to the null_value option?
This same ambiguity exists in the canonical JSON to proto3 mapping (https://protobuf.dev/programming-guides/proto3/#json). In Proto3, {value_field: null}
parses to a Value
of kind null_value
rather than Value
default instance.
Given that the CEL spec matches the conversion from proto3 for primitive wrapper types,
CEL spec:
field selection of an unset message field of wrapper type will evaluate to
null
Proto3 JSON spec:
Wrappers use the same representation in JSON as the wrapped primitive type, except that null is allowed and preserved during data conversion and transfer
I'd argue that when converting to proto3, Value (which exists to be a proto representation of JSON) should also match the proto3 JSON behavior and interpret value_field: null as null_value
rather than unset.
from cel-spec.
Additionally, the canonical JSON to proto3 mapping notes that JSON null
is accepted in message types to mean "default instance", and accepted in list types to mean "empty list".
from cel-spec.
Related Issues (20)
- Support jq x[] operation
- Support bitwise operators HOT 3
- C spex
- Link to the implementation dashboard is broken. HOT 1
- Function Definitions and Variables HOT 2
- Protobuf extensions HOT 2
- Checking for undeclared reference HOT 1
- hobo HOT 1
- Monaco Editor language support HOT 4
- What does the `~*` mean? HOT 1
- [question] Duplicate/unique check expression HOT 2
- Bzlmod for v0.14.0
- Add access to the descriptor (of a protobuf message). HOT 1
- .
- Pięknie chyba się udalo
- Będzie dobrze
- Internet, telefonia i telewizja | Plus
- Should `optional.none()` == `null` ? HOT 2
- is this a good language to use a FaaS solution?
- Does the getHours() method use Winter or Daylight Saving Time? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cel-spec.