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

Eric Anderson commented on THRIFT-72:
-------------------------------------

I can't commit (no permission), and the related problem is that the patch as 
written isn't actually useful to us; we want the constructor argument order to 
match with the order in the thrift file.

consider the following evolution of a structure:

struct circle {
   required 1: i32 x;
   required 2: i32 y;
   required 3: i32 radius;
}

--- V2: (assuming a series of intermediate ones with the necessary optionals)

struct point {
   required 1: i32 x;
   required 2: i32 y;
}

struct circle {
   required 4: point center;
   required 3: i32 radius;
}

The problem is that the latter circle is now initialized as circle(radius, 
center), which seems inverted to me from the "expected" order for defining such 
an object.  However, I can't reuse the 1 and 2 tags because they are obsolete 
(as I understand the thrift migration of structure tag rules)

I'd planned to put in an option to control which way the constructors would go 
it, but I got busy.

Out of curiosity, is there a reason that you're replacing \n with endl?  They 
are exactly the same except that endl is equivalent to \n + flush output, so is 
strictly slower. 
(http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?id=1043284376&answer=1045690279)
 -- we had this argument internally, and tested it on windows, \n in a string 
generated \x0a\x0d in a file.


>  C++ structure constructor
> --------------------------
>
>                 Key: THRIFT-72
>                 URL: https://issues.apache.org/jira/browse/THRIFT-72
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (C++)
>         Environment: Tested on debian stable (etch)
>            Reporter: Eric Anderson
>            Assignee: Alexander Shigin
>            Priority: Minor
>             Fix For: 0.1
>
>         Attachments: 
> 0001-THRIFT-72.-cpp-Add-a-struct-constructor-that-takes.patch, 
> structure-constructor.patch, thrift-cpp-constructor-v2.patch, 
> thrift-cpp-constructor-v3.patch, thrift-cpp-constructor-v4.patch, 
> thrift-cpp-constructor-v5.patch
>
>
> We're mostly using the C++ interface to thrift, and I wanted to be
> able to initialize structures more easily than a whole series of lines
> that set each of the parameters separately.  Attached is a patch that
> adds a constructor to the C++ objects that allow you to fully
> initialize an object in a single call.  I added two tests for this,
> one in the DebugProtoTest.cpp file, and one in the
> OptionalRequiredTest.cpp.  The patch is against the 20080411p1 release.

-- 
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