<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="">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></body></html>