Skip to content
Tcl Source Code View Ticket
Login

View Ticket

modernize [file stat] interface

Closed / Accepted560c5e438c47f5fdd34846dbb333ab96cb905416Created 6 years agoUpdated 3 years ago
Descriptionplain2021-01-05 16:14:16
This change makes the `varName` argument to [file stat] optional, introducing a 
1-argument form.  The 2-argument form is unchanged.  The new 1-argument form 
produces the same errors, but on success returns its result as a dictionary 
instead of populating an array in the caller's namespace.  The dictionary result 
is identical with what would be stored in the array.  Calling [file stat] with 
one argument previously raised a {TCL WRONGARGS} error, so this change can be 
considered backward-compatible.

Returning a dictionary is beneficial in that it can be passed & returned by value 
between procs, it can be processed by [dict] commands and the caller has full 
control over whether and how to store it in a variable.

Attached patch implements such behaviour.  Note that tests cmdAH-28.1 and 
cmdAH-28.2 are affected by this change. The patch address this issue as well.
aspect Ticket [560c5e438c]: 3 changes [History diff]2021-01-13 03:07:26
oehharwiki2021-01-13 08:23:30

Emiliano,

I appreciate your great contribution. As it is a user visible change, a TIP is required. If you don't have commit rights to core.tcl-lang.org/tips , please ask for it to drive the process.

Thank you, Harald

aspectplain2021-01-13 12:26:39
https://core.tcl-lang.org/tips/doc/trunk/tip/594.md

Listed Emiliano as primary author since he contributed the idea and the patch.  Any errors in the tip text are mine.
dkfhtml2021-01-14 10:00:34

Looks like a good change to me.

emilianoplain2021-01-14 14:58:49
Added a new patch with the same changes for [file lstat]. Both commands share semantics and implementation, so it seems to me incomplete to implement the change for one and leave the other as is.
TIP 594 should be updted to reflect this change.
emilianoplain2023-07-11 12:48:11
TIP 594 accepted. It will be available on 8.7
Log in (anonymous is fine) to add a comment.