Thread View: comp.lang.misc
1 messages
1 total messages
Started by Tristan Wibberley
Thu, 12 Nov 2026 18:32
Re: Why is variable shadowing a thing in Rust?
Author: Tristan Wibberley
Date: Thu, 12 Nov 2026 18:32
Date: Thu, 12 Nov 2026 18:32
38 lines
3081 bytes
3081 bytes
On 22/09/2026 18:50, Stefan Ram wrote:
> Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>> the book talks about shadowing variables, with a completely new type.
>
> The Rustafarians think that
>
> let input = input.trim();
>
> is clearer, because the name "input" always represents the same
> concept, and it becomes impossible to inadvertently use the un-
> trimmed input later. (One also might think of every "let" in a
> block opening a kind of "new scope".)
In fact it's the semi-colon doing that isn't it? Following the age-old
form of so many languages in which (pseudo-grammar):
implicit-scope : statement ';' implicit-scope
| statement ';'
'let' just takes advantage of the new implicit-scope to cons a
dictionary overlay (or in this case an individual identifier definition)
onto a definitions dictionary stack at compile time (if you view a
compiler as an interpreter that compiles instead of executing).
--
Tristan Wibberley
The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads