--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 5A12E429E32\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 03:19:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id DARjGxw-64Yz for <notmuch@notmuchmail.org>;\r
+ Thu, 24 Oct 2013 03:19:31 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 933BB429E29\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 03:19:31 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 2CFBD100217;\r
+ Thu, 24 Oct 2013 13:19:22 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: David Bremner <david@tethera.net>, Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH 1/3] cli: add insert --must-index option\r
+In-Reply-To: <87ob6fv8he.fsf@zancas.localnet>\r
+References: <1374365254-13227-1-git-send-email-novalazy@gmail.com>\r
+ <87ip048gbj.fsf@qmul.ac.uk>\r
+ <20130727151510.GA13750@hili.localdomain>\r
+ <87hadtxfrr.fsf@qmul.ac.uk>\r
+ <20130912001349.GA18821@hili.localdomain>\r
+ <87zjqhv264.fsf@zancas.localnet>\r
+ <m238o9fguj.fsf@guru.guru-group.fi> <87bo2xtdp2.fsf@unb.ca>\r
+ <m2eh7bu7t5.fsf@guru.guru-group.fi>\r
+ <20131023193209.GF20337@mit.edu> <87ob6fv8he.fsf@zancas.localnet>\r
+User-Agent: Notmuch/0.16+115~g11c2ff5 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 24 Oct 2013 13:19:22 +0300\r
+Message-ID: <m27gd3q8d1.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 24 Oct 2013 10:19:39 -0000\r
+\r
+On Thu, Oct 24 2013, David Bremner <david@tethera.net> wrote:\r
+\r
+> Austin Clements <amdragon@MIT.EDU> writes:\r
+>\r
+>> And in libnotmuch, we would do something like\r
+>>\r
+>> notmuch_status_t\r
+>> notmuch_database_open (const char *path,\r
+>> notmuch_database_mode_t mode,\r
+>> const notmuch_options_t *options,\r
+>> notmuch_database_t **database)\r
+>> {\r
+>> notmuch_option_t real_options = NOTMUCH_OPTIONS_INIT;\r
+>> if (real_options.options_length < options.options_length)\r
+>> return error;\r
+>> memmove(&real_options, options, options.options_length);\r
+>> // ...\r
+>> }\r
+>>\r
+>\r
+> Does the C standard guarantee that if two structs have the same initial\r
+> set of members, that they are aligned in a compatible way? I suppose it\r
+> must work, but I'm still curious.\r
+\r
+If we have structures\r
+\r
+struct s1 { \r
+ long l1;\r
+ void * vp1;\r
+ short s1;\r
+ int i1;\r
+ char c1;\r
+}\r
+\r
+&\r
+\r
+struct s2 { \r
+ long l1;\r
+ void * vp1;\r
+ short s1;\r
+ int i1;\r
+ char c1;\r
+ char c2;\r
+ // void * vp2;\r
+};\r
+\r
+The variables l1, vp1, s1, i1 & c1 have same offset from the beginning of\r
+structure and uses same amount of space in both structures...\r
+\r
+... now the interesting point is what is the size of the structures (does C\r
+compiler add padding to the end (to make the size multiple of something ?)\r
+In any case all the other data is zeroed in the structure and sizeof data\r
+is copied to "real" structure if Austin's suggestion is used...\r
+\r
+> Yet another approach would be to pass in array of descriptors, something\r
+> like the command line argument parsing code does now.\r
+>\r
+> libnotmuch_opt_desc_t options[] = {\r
+> { LIBNOTMUCH_OPT_LOGHOOK, loghook },\r
+> { 0, 0} \r
+> }\r
+>\r
+> I guess passing a (void *) as the second element of the pair?\r
+\r
+Voidp and only that. Then we can hack other variables using\r
+((char *)0 + (intvar)) or GINT_TO_POINTER... -- beautiful, eh ? ;)\r
+\r
+> Of course it's a bit more work to unpack this way.\r
+\r
+That is negligible to the elegance loss -- and what about bindings ! >;)\r
+\r
+\r
+Tomi\r