Giter VIP home page Giter VIP logo

Comments (5)

alubbe avatar alubbe commented on September 24, 2024

Could you elaborate a little bit on a) why and b) what that means?
Specifically, I get these warnings

warning: [UNSUPPORTED] Ignoring default value "" for text field foo. 
warning: [UNSUPPORTED] Ignoring non-null default for list field bar. 

for these fields

  foo @1: Text = "";
  bar @2: List(UInt32) = [];

from capnpc-rust.

dwrensha avatar dwrensha commented on September 24, 2024

Ah, good point. We probably shouldn't be emitting a warning when an explicit default matches whatever the implicit default would be.

These field definitions, with explicit defaults:

  foo @1: Text = "";
  bar @2: List(UInt32) = [];

have the same meaning as these definitions with implicit defaults:

  foo @1: Text;
  bar @2: List(UInt32);

In general, every field always has a default. The implicit default for a primitive field is zero. The implicit default for a list field is the empty list, and the implicit default for a struct field has a zeroed data section and an all-null pointer section.

For pointer fields, you can distinguish between "default" and "null" by using a has_foo() accessor. If you call get_foo() and the foo field contains a null pointer, you'll get the default value.

from capnpc-rust.

dwrensha avatar dwrensha commented on September 24, 2024

I've somewhat improved the situation here: 4216741

Unfortunately, it's not trivial to detect when the warning should be suppressed in the List and Struct cases.

from capnpc-rust.

dwrensha avatar dwrensha commented on September 24, 2024

Could you elaborate a little bit on a) why

The warning is to make sure you're aware that pointer defaults are currently unimplemented in capnpc-rust.

Of course, the long-term solution here is to actually implement pointer defaults. I think doing so should be fairly straightforward, but I haven't done it yet because I haven't needed to.

from capnpc-rust.

dwrensha avatar dwrensha commented on September 24, 2024

Fixed in: capnproto/capnproto-rust@f9ae25c

from capnpc-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.