[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: left hand reference operator in assignment
- From: Rob Kendrick <rjek@...>
- Date: Thu, 10 Apr 2014 15:08:02 +0100
On Thu, Apr 10, 2014 at 06:59:29AM -0700, stuart@testtrack4.com wrote:
> This is a simple syntactic sugar addition that would make code a lot
> easier to maintain and refactor, and make idioms much clearer. I've been
> thinking about how I'd want something like this for a long time, and I
> think I've finally come up with how it could work.
>
> The idea is simple: allow a fixed character on the right-hand side of an
> assignment statement to refer to the left-hand variable(s). For example,
> if I have a variable like this:
>
> local extremely_long_variable_name = 1
>
> and I want to increment it by 1, I have to type its name twice:
>
> extremely_long_variable_name = extremely_long_variable_name + 1
This comes up a lot. I think the cleanest, most elegant solution that
does not introduce magical syntax or complex decisions about metamethods
is to use shorter variable names. Or a macro in your text editor.
B.