Page MenuHomeFeedback Tracker

Make "private" command return the variable reference
New, WishlistPublic

Description

Right now the "private" command returns "Nothing" type. When used with a single (string) argument - it could return the local variable reference, allowing you to initialize local scoped variables like this:

private "_my" = [code];

Instead of current:

private "_my";
_my = [code];

Details

Legacy ID
1384555784
Severity
None
Resolution
Open
Reproducibility
N/A
Category
Scripting

Event Timeline

simast edited Steps To Reproduce. (Show Details)May 14 2013, 11:17 AM
simast edited Additional Information. (Show Details)
simast set Category to Scripting.
simast set Reproducibility to N/A.
simast set Severity to None.
simast set Resolution to Open.
simast set Legacy ID to 1384555784.May 7 2016, 2:06 PM

My personal trick:

<i>
#define var(x) private #x; x

var(_my) = "test";
</i>

Expands to:

<i>private "_my"; _my = "test";</i>

simast added a subscriber: simast.May 7 2016, 2:06 PM

@Deadfast: that's neat. Also, no impact on the runtime performance as this is a pre-processor. Nice, thanks for the tip!

dedmen added a subscriber: dedmen.Sep 13 2017, 1:29 PM

Superceded by private keyword.. Also local already existed back then and could do exactly what was requested here.
@simast That does impact runtime performance. As you the Macro does exactly the same as private "_var";_var = "test"