Struct-valued constants are not yet implemented
See original GitHub issueAs it stands today, the current thrifty schema is not able to parse struct valued constants. Wanted to know if this is a work in progress? If not, was this something consciously left out from implementation?
I am trying to load schemas for manipulating certain exceptions based on added annotations. Given that we only care about exceptions structs, is it possible to silently fail the constant schema generation so that it does not throw IllegalStateException
?
Several of our thrift definitions have struct valued constants so wondering if there is any workaround?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
suboptimal compilation of struct-valued switch statements ...
The integer constant cases are implemented as a binary search; the struct cases are implemented as linear search.
Read more >Why is the Copy trait needed for default (struct valued) array ...
Copy does not contain methods; it exists solely to mark that implementing types have certain property and so it is usually called a...
Read more >Compile-Time Constant Expressions for Swift
Chris Lattner and I have been working on a proposal to add compile-time constant expressions to Swift. Our goal is to create a...
Read more >Java-centric foreign metadata - Community Code Review
Extracted interfaces can be implemented directly for maximum performance. ... Fields will not be used to model constant values. Java interface subtyping ...
Read more >C++ Serialization - Cap'n Proto
Other compilers have not been tested at this time. This implementation prefers to handle errors using exceptions. Exceptions are only used in circumstances ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @benjamin-bader for the pointers. The apache compiler does support it as we have plenty of struct-defined constants and use the generated code. I am taking a stab at the
Loader
to see if I can add a ConstValidator implementation for struct valued constants. TheAntlrThrift.g4
has support for loading the struct valued constant as the grammar is in line with what Thrift grammar has.AntlrThrift.g4
constDef : 'const' fieldType IDENTIFIER '=' constValue separator? ;
https://thrift.apache.org/docs/idl#const
Const ::= 'const' FieldType Identifier '=' ConstValue ListSeparator?
I will leave out the code gen part at this time as the immediate requirement is to be able to load the schema.
Nice, I’ll look forward to it! It’s been so long since I’ve worked on the schema project that I completely forgot that we absolutely did intend to do this. Turns out we never had the need so it fell off my radar.
You’re right that
ConstValidator
is where the work needs to happen; sounds like you’ve already figured out everything you need. Let me know how I can help, if you hit any issues!