{"id":1851,"date":"2012-10-17T20:00:59","date_gmt":"2012-10-17T19:00:59","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=1851"},"modified":"2012-09-23T09:16:43","modified_gmt":"2012-09-23T08:16:43","slug":"product-types-in-alfe","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/product-types-in-alfe\/","title":{"rendered":"Product types in ALFE"},"content":{"rendered":"<p>This is part of the <a href=\"https:\/\/www.reenigne.org\/blog\/the-alfe-type-system\">ALFE types series<\/a>.<\/p>\n<p><strong>(Foo, Bar)<\/strong> is a \"product\" type, aka <strong>Tuple&lt;Foo, Bar&gt;<\/strong> or a structure with unnamed fields. <strong>Tuple<\/strong> is another variadic template, so <strong>(Foo, Bar, Baz)<\/strong> is syntactic sugar for <strong>Tuple&lt;Foo, Bar, Baz&gt;<\/strong>. Values of <strong>Tuple<\/strong> type are written in the same way as the type itself, except with values instead of types inside the parentheses: <strong>(foo, bar)<\/strong>. You can have tuples of LValues as well as RValues, which is handy for functions that return <strong>Tuple<\/strong> values:<\/p>\n<pre lang=\"c\">(foo, bar) = getFooBar();<\/pre>\n<p>You can also have a tuple of declarations:<\/p>\n<pre lang=\"c\">(Foo foo, Bar bar) = getFooBar();<\/pre>\n<p><strong>(Foo)<\/strong> is identical to <strong>Foo<\/strong> just as it is in C, but in ALFE it's also a 1-tuple (so 1-tuplifying is really just a no-op). There is also a single 0-tuple type <strong>()<\/strong> aka <strong>Tuple&lt;&gt;<\/strong> which is another name for <strong>Null<\/strong>. There is a single value inhabiting this type, which is also (by slight abuse of notation that took me a while to determine wasn't too amiguous or confusing) called <strong>()<\/strong> and <strong>Null<\/strong> (a type specifier can be used as a value if it is default-constructable).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is part of the ALFE types series. (Foo, Bar) is a \"product\" type, aka Tuple&lt;Foo, Bar&gt; or a structure with unnamed fields. Tuple is another variadic template, so (Foo, Bar, Baz) is syntactic sugar for Tuple&lt;Foo, Bar, Baz&gt;. Values of Tuple type are written in the same way as the type itself, except with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,27],"tags":[],"class_list":["post-1851","post","type-post","status-publish","format-standard","hentry","category-computer","category-language"],"_links":{"self":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/comments?post=1851"}],"version-history":[{"count":3,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1851\/revisions"}],"predecessor-version":[{"id":1853,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1851\/revisions\/1853"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=1851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=1851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=1851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}