Modify

Opened 11 years ago

Closed 4 years ago

#2503 closed Feature Request (Rejected)

Reference Definition Keyword

Reported by: Tasiro Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: reference, ref, byref Cc:

Description

It is possible to create a reference, but only with a complicated syntax:

Local $var = 1
rest ($var)
Func rest (ByRef $var_ref)
    $var = 2 ; $var_ref == 2
    $var_ref = 3 ; $var == 3
EndFunc

Please change the syntax to make the definition of references easier.
The production is something like:
variable-declarationvariable-declaration-specifiers variable-name.
Please change that to:
variable-declarationvariable-declaration-specifiers Refopt variable-name.

Then, it would just be:

Local $var = 1
Local Ref $var_ref = $var ; same rules as for ByRef argument
$var = 2 ; $var_ref == 2
$var_ref = 3 ; $var == 3

Attachments (0)

Change History (5)

comment:1 Changed 11 years ago by anonymous

ByRef cannot compute

comment:2 Changed 9 years ago by mLipok

Why do you need the exactly the same content in variable in the same scope but with different variable name ?
To me this seems ridiculous, or at least unnecessary.

Last edited 9 years ago by mLipok (previous) (diff)

comment:3 Changed 8 years ago by anonymous

Maybe for this:

ref $r = $array [calculateIndex ()]

Or something similar to this:

func getFirstNonArray (ByRef $array, $then)
    ref $r = $array
    while IsArray ($r)
        ref $r = $r [0]
    wend
    $then ($r)
endfunc

func exampleThen (ByRef $part)
    ; modify $part
endfunc

Creating a reference makes iterative variants of otherwise stack overflow generating functions possible.

comment:4 Changed 8 years ago by mLipok

So I little change you example (now is be more readeble):

Func getFirstNonArray(ByRef $array, $function)
	ref $aTemp = $array
	While IsArray($aTemp)
		ref $aTemp = $aTemp[0]
	WEnd
	$function($aTemp)
EndFunc   ;==>getFirstNonArray

Func exampleThen(ByRef $part)
	; modify $part
EndFunc   ;==>exampleThen


Your example does exactly the same as this:

Func getFirstNonArray(ByRef $array, $function)
	While IsArray($array)
		$array = $array[0]
	WEnd
	$function($array)
EndFunc   ;==>getFirstNonArray

Func exampleThen(ByRef $part)
	; modify $part
EndFunc   ;==>exampleThen


What advantage do you see in your example ?

comment:5 Changed 4 years ago by Jpm

  • Resolution set to Rejected
  • Status changed from new to closed

no more info

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.