[ 
https://issues.apache.org/jira/browse/THRIFT-339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12672808#action_12672808
 ] 

David Reiss commented on THRIFT-339:
------------------------------------

I think it was a tuple for performance reasons.  I just thought of a way that 
we might be able to simplify both this issue and THRIFT-105.  tuples can take 
negative indexes (indices?) just like lists, and they are counted from the end. 
 What if we just extended the thrift_spec tuple so that all of the negative 
fields were in the right place (after all of the positive fields)?  So if you 
had a struct like
{code}
struct foo {
  i32 bar;
  i32 baz;
  2: i32 qux;
}
{code}
then the thrift_spec would look like
{code}
(
BLANK, # 0 aka -5
BLANK, # 1 aka -4
spec_for_qux, # 2 aka -3
spec_for_baz, # 3 aka -2
spec_for_bar, # 4 aka -1
)
{code}
This would not disturb the existing thrift_spec fields at all, so the current 
fastbinary extension would work fine.  It should be robust against adding new 
negative fields to the end, since the indexes (indices?) of the existing fields 
will not change.  I think it would make the patch for THRIFT-105 a lot simpler 
too, though we might need a little bit of magic to make sure that negative 
indexes work in the C code.

Thoughts?

> THRIFT-242 is incompatible with arguments with empty key fields
> ---------------------------------------------------------------
>
>                 Key: THRIFT-339
>                 URL: https://issues.apache.org/jira/browse/THRIFT-339
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Python)
>            Reporter: Jonathan Ellis
>
> Esteve's last change to how default values are stored broke stuff.  Here is a 
> quick example:
> {{
> service Test
> {
>   bool  get_slice(i32 start = -1),
> }
> }}
> generates
> {{
> class get_slice_args:
>   thrift_spec = None
>   def __init__(self, start=thrift_spec[-1][4],):
>     self.start = start
> }}
> which is obviously invalid.
> I'm not sure how thrift_spec is supposed to be populated here so I'm unsure 
> how to fix this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to