|
2008-01-29
| ||
| 06:55 | • Ticket [1880941fff] lassign behavior on excess arguments status still Open w... artifact: da12c438da user: dkf | |
| 00:06 | • Ticket [1880941fff]: 4 changes artifact: 76316efb47 user: coldstore | |
|
2008-01-28
| ||
| 22:02 | • Ticket [1880941fff]: 1 change artifact: efafe97caa user: dkf | |
| 22:02 | • Ticket [1880941fff]: 4 changes artifact: bba21ad01c user: dkf | |
| 21:53 | • Ticket [1880941fff]: 4 changes artifact: 8b3254303e user: dgp | |
| 03:42 | • New ticket [1880941fff]. artifact: 4ce9c88c10 user: coldstore | |
lassign behavior on excess arguments
Open1880941fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-01-28 03:42:22
[set y 1; lassign a x y; set y] returns "", I think it should return 1. Commonly [lassign] is used to assign a list of values to variables, as (for example) a way of interpreting multiple return values. In the case that there's no value, it's useful to be able to assign a default. The proposed behavior, that unmatched variables be left alone, permits one to implement defaulting behavior, example: lassign $defaults x y z lassign [function] x y z Where the current behavior requires a fairly tedious series of [if] if one needs to distinguish between defaulted values and "".
dgpplain2008-01-28 21:53:30
Logged In: YES user_id=80530 Originator: NO see also 1671880
dkfplain2008-01-28 22:02:08
Logged In: YES user_id=79902 Originator: NO The proposed change is more expensive to implement (needs more elaborate bytecode generation).
dkf Ticket [1880941fff]: 1 change
[History diff]2008-01-28 22:02:09
coldstoreplain2008-01-29 00:06:06
Logged In: YES user_id=19214 Originator: YES I find it counterintuitive that (as dkf claims) not touching a variable leads to more bytecode than initializing it to "", but it may well be the case.
dkfplain2008-01-29 06:55:31
Logged In: YES
user_id=79902
Originator: NO
It's because [lindex {1 2 3} 4] is {} (not an error) and in the no-assign case I'd need to generate extra code to detect when the list is exhausted and stop assigning. Right now, I generate jump-free code...
Log in (anonymous is fine) to add a comment.