lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Griffin Rock once stated:

> Proposed ability to 'mark' an argument in an imperative function call to
> transform it into an assignment statement. Can be implemented as a purely
> syntactic translation with no change to the behaviour of the function or
> interpreter. Syntax below uses unary '&' like c pointers and c++ reference
> signatures.

  '&' is used in Lua 5.3+ as the logical AND operator, so it might be a poor
choice.  Perhaps '@' (the AT symbol) is better.

> examples of use:

> "trim(x, & veryLongName, z)" => "veryLongName = trim(x, veryLongName, z)"
> "string.gsub(& line, '%s+', ' ')" => "line = string.gsub(line, '%s+', ' ')"

	trim(x,@veryLongName,z)
	string.gsub(@line,'%s+',' ')

> probably only useful on locals, since you can already "manually" translate
> 
> "trim(& veryLongName[complexLValue])" => "zap(trim, veryLongName, complexLValue)"

  Well, another pain point is

	veryLongNmae[complexLValue] = veryLongName[complexLValue] + 1

so if the intent is to somehow reference these, you could probably extend
the syntax with the following:

	veryLongName = trim(x,@,z)
	line = @:gsub('%s+',' ')
	veryLongName[complexLValue] = @ + 1

This still shows the assignment, which in my book is still important. And
further more:

	veryLongName,complexLValue = @2,@1

where, in this case:

	@1 = veryLongName
	@2 = complexLValue

  I'm not sure if I like it though.  Part of me loves the idea of not having
to type "veryLongName[complexLValue]" several times (avoiding typos), but
the other half of me keeps saying "You hate Perl and it's implicit magic ..."

  -spc