<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">An lvalue is something that can be assigned to / changed. The terminology comes from assignment statements: in “foo = bar”, “foo” is a left-value (lvalue) and “bar" is a right-value (rvalue). The difference is that the lvalue is a named location that can take on a new value and an rvalue is just a plain value.</div><div class=""><br class=""></div><div class="">See: <a href="https://en.wikipedia.org/wiki/Value_(computer_science)#lrvalue" class="">https://en.wikipedia.org/wiki/Value_(computer_science)#lrvalue</a></div><div class=""><br class=""></div><div class="">In Swift’s AST, you’ll see @lvalue as the type coming from a declaration reference (declref) for var’s and for inout parameters inside a method implementation. You’ll see function application require @lvalue types for inout parameters (most of which will be the implicit first parameters of ‘mutating’ functions - the thing to be mutated). A load converts an expression from an lvalue to being an rvalue, and a store takes an lvalue and a new rvalue to be put there.</div><div class=""><br class=""></div><div class="">Hope this helps!</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- Greg</div><br class=""><div><blockquote type="cite" class=""><div class="">On May 24, 2016, at 9:48 AM, Tim Bodeit via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I couldn’t find any documentation about lvalues in Swift. Can anybody give me a short explanation of what exactly an lvalue is?<div class=""><br class=""></div><div class="">In C++ all variables, including those marked with the <font face="Menlo" class="">const</font> modifier seem to be lvalues. It seems to me, that this is not the case for <font face="Menlo" class="">let</font> constants in Swift.</div><div class=""><br class=""></div><div class="">I compared the output of <font face="Menlo" class="">swiftc -dump-ast</font> for </div><div class=""><span style="font-family: Menlo;" class="">let i = 42</span></div><div class=""><div class=""><font face="Menlo" class="">let j = i+1</font></div></div><div class="">and</div><div class=""><div class=""><span style="font-family: Menlo;" class="">var i = 42</span></div><div class=""><font face="Menlo" class="">let j = i+1</font></div></div><div class=""><br class=""></div><div class="">Where <font face="Menlo" class="">i</font> was respectively accessed as:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">(<font color="#d95000" class="">declref_expr type='Int'</font> location=lvaluetest.swift:2:9 range=[lvaluetest.swift:2:9 - line:2:9] decl=lvaluetest.(file).<a href="mailto:i@lvaluetest.swift" class="">i@lvaluetest.swift</a>:1:5 direct_to_storage specialized=no)</font></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">(load_expr implicit type='Int' location=lvaluetest.swift:2:9 range=[lvaluetest.swift:2:9 - line:2:9]</font></div><div class=""><font face="Menlo" class=""> (<font color="#d95000" class="">declref_expr type='@lvalue Int'</font> accessKind=read location=lvaluetest.swift:2:9 range=[lvaluetest.swift:2:9 - line:2:9] decl=lvaluetest.(file).<a href="mailto:i@lvaluetest.swift" class="">i@lvaluetest.swift</a>:1:5 direct_to_storage specialized=no))</font></div></div><div class=""><br class=""></div><div class="">Is my assumption correct, that let constants are not lvalues?</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Tim</div></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-dev<br class=""></div></blockquote></div><br class=""></body></html>