[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: RFC: "in place" return from imperative function calls
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Wed, 14 Aug 2019 17:03:52 -0300
On 2019-08-14 3:50 p.m., pocomane wrote:
On Wed, Aug 14, 2019 at 4:05 AM Griffin Rock <email@example.com> wrote:
> > veryLongName = trim(x,@,z)
> > line = @:gsub('%s+',' ')
> > veryLongName[complexLValue] = @ + 1
> > This still shows the assignment, which in my book is still important.
> Agreed - I like your idea better.
Summarizing the proposal to: An `@` on the right side of an assignment
is replaced with the old value of the first variable on the left side.
(Another token instead of `@` can be used).
As you, I also think that it solves several "Ugliness" of the code,
e.g. the long identifier repetition, or the "a = a + 1" lines due to
the absence of "+=" operator.
The only conceptual drawback that I can find is the following. Right
now I can easily recognize the places where a variable is read, but it
could become tricky in lines like `long_name_1 = func( long_name_2,
long_name_3, @, long_name_4 )`.
Moreover, there are the usual criticisms: it is another syntax to
learn, does it worth? Does it introduce too complexity to the parser?
And so on.
Probably we need a patch to give it a try.
how about @self (returns the currently executing function object), @var
(returns the value of the variable being assigned to) and @table
(returns the table being currently constructed)?
(@table would be particularly useful for some DSLs. note that all of
these only affect the local lexical scope and don't work across
modules/function call boundaries.)