From: <apn...@ya...> - 2024-07-24 08:04:48
|
% clock scan now 1721803544 % clock format now bad seconds "now": must be -now or integer % clock format -now Wed Jul 24 12:16:03 IST 2024 The above seems incongruous to me, why -now for format and "now" for scan? Afaict, "-now" is really a value, not an option. And unlike options, it cannot appear at arbitrary points in the command, only in place of the time value. Is there a rationale for the difference? If no, is it too late to change for 9.0? If too late for compatibility reasons, can clock format and clock add treat "now" and "-now" as synonyms with latter deprecated? (With a TIP of course) /Ashok |
From: Schelte B. <tc...@tc...> - 2024-07-26 20:43:30
|
I totally agree. The value "-now" looks like it's an option, but it's clearly not. You can't use [clock format -format %T -now]. Being a value rather than an option, it would then have to be interpreted as "negative now". But that doesn't make any sense. What the value is supposed to be is shorthand for [clock seconds], similar to how "end" is shorthand for [expr {[string length $str] - 1}] in [string index $str end]. In that case we don't use "-end". Equally, it shouldn't be "-now" for clock format. Maybe at some point in the future, it may even be deemed useful to allow simple arithmetic on the value, just like with end. For example to easily create an expires header: set expires [clock format now+3600 -format $datefmt -timezone UTC] Having to write that as "-now+3600" would be even more confusing than just "-now" already is. I'm not saying that allowing simple arithmetic on "now" is worth the trouble, but who knows what the future may bring? There is no reason to make that possibility more awkward than it has to be. I can imagine that not a lot of thought has gone into naming the shorthand value, as it was introduced as part of a much larger rewrite of the implementation of the clock command. It was just a quick and simple "nice to have" addition. But please, let's get this corrected before it starts to be used in so many scripts that we're stuck with it until Tcl 10. Schelte. On 24/07/2024 10:04, apnmbx-public--- via Tcl-Core wrote: > % clock scan now > > 1721803544 > > % clock format now > > bad seconds "now": must be -now or integer > > % clock format -now > > Wed Jul 24 12:16:03 IST 2024 > > The above seems incongruous to me, why -now for format and “now” for scan? > > Afaict, “-now” is really a value, not an option. And unlike options, it > cannot appear at arbitrary points in the command, only in place of the > time value. > > Is there a rationale for the difference? If no, is it too late to change > for 9.0? If too late for compatibility reasons, can clock format and > clock add treat “now” and “-now” as synonyms with latter deprecated? > (With a TIP of course) > > /Ashok > > > > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core |
From: Harald O. <har...@el...> - 2024-07-27 12:40:30
Attachments:
OpenPGP_signature.asc
|
Schelte, Ashok, I think, we are on the wrong track. There are two forms of "now", one for free form scan ("now"), one for "[clock seconds]" replacement ("-now"). They should be different. Due to that, Sergey has chosen "-now" and "now" (what was already there). At least, that is the way I understand the post by Sergey to the ticket: https://core.tcl-lang.org/tcl/info/cd25761979da7be2 Take care, Harald Am 26.07.2024 um 22:38 schrieb Schelte Bron: > I totally agree. The value "-now" looks like it's an option, but it's > clearly not. You can't use [clock format -format %T -now]. Being a value > rather than an option, it would then have to be interpreted as "negative > now". But that doesn't make any sense. > > What the value is supposed to be is shorthand for [clock seconds], > similar to how "end" is shorthand for [expr {[string length $str] - 1}] > in [string index $str end]. In that case we don't use "-end". Equally, > it shouldn't be "-now" for clock format. > > Maybe at some point in the future, it may even be deemed useful to allow > simple arithmetic on the value, just like with end. For example to > easily create an expires header: > > set expires [clock format now+3600 -format $datefmt -timezone UTC] > > Having to write that as "-now+3600" would be even more confusing than > just "-now" already is. > > I'm not saying that allowing simple arithmetic on "now" is worth the > trouble, but who knows what the future may bring? There is no reason to > make that possibility more awkward than it has to be. > > I can imagine that not a lot of thought has gone into naming the > shorthand value, as it was introduced as part of a much larger rewrite > of the implementation of the clock command. It was just a quick and > simple "nice to have" addition. But please, let's get this corrected > before it starts to be used in so many scripts that we're stuck with it > until Tcl 10. > > > Schelte. > > > On 24/07/2024 10:04, apnmbx-public--- via Tcl-Core wrote: >> % clock scan now >> >> 1721803544 >> >> % clock format now >> >> bad seconds "now": must be -now or integer >> >> % clock format -now >> >> Wed Jul 24 12:16:03 IST 2024 >> >> The above seems incongruous to me, why -now for format and “now” for >> scan? >> >> Afaict, “-now” is really a value, not an option. And unlike options, >> it cannot appear at arbitrary points in the command, only in place of >> the time value. >> >> Is there a rationale for the difference? If no, is it too late to >> change for 9.0? If too late for compatibility reasons, can clock >> format and clock add treat “now” and “-now” as synonyms with latter >> deprecated? (With a TIP of course) >> >> /Ashok |
From: Schelte B. <tc...@tc...> - 2024-07-27 19:13:20
|
Hello Harold, Thanks for pointing me at the ticket. I was not aware of its existence. But note that I did not mention clock scan at all. Simply based on what it means in the clock format command, "now" makes much more sense than "-now". I also don't agree that two different commands couldn't use the same word for slightly different things. After all both lindex and string index accept the value "end". One for addressing a list element and the other for a character. In the ticket I see that "-now" can also be used as the value for the "-base" option. In that usage it's even stranger to use a (quasi) option as the value for another option. I will update the ticket with my point of view. Thanks, Schelte. On 27/07/2024 14:40, Harald Oehlmann wrote: > Schelte, Ashok, > > I think, we are on the wrong track. There are two forms of "now", one > for free form scan ("now"), one for "[clock seconds]" replacement ("-now"). > > They should be different. Due to that, Sergey has chosen "-now" and > "now" (what was already there). > > At least, that is the way I understand the post by Sergey to the ticket: > https://core.tcl-lang.org/tcl/info/cd25761979da7be2 > > Take care, > Harald > > > Am 26.07.2024 um 22:38 schrieb Schelte Bron: >> I totally agree. The value "-now" looks like it's an option, but it's >> clearly not. You can't use [clock format -format %T -now]. Being a >> value rather than an option, it would then have to be interpreted as >> "negative now". But that doesn't make any sense. >> >> What the value is supposed to be is shorthand for [clock seconds], >> similar to how "end" is shorthand for [expr {[string length $str] - >> 1}] in [string index $str end]. In that case we don't use "-end". >> Equally, it shouldn't be "-now" for clock format. >> >> Maybe at some point in the future, it may even be deemed useful to >> allow simple arithmetic on the value, just like with end. For example >> to easily create an expires header: >> >> set expires [clock format now+3600 -format $datefmt -timezone UTC] >> >> Having to write that as "-now+3600" would be even more confusing than >> just "-now" already is. >> >> I'm not saying that allowing simple arithmetic on "now" is worth the >> trouble, but who knows what the future may bring? There is no reason >> to make that possibility more awkward than it has to be. >> >> I can imagine that not a lot of thought has gone into naming the >> shorthand value, as it was introduced as part of a much larger rewrite >> of the implementation of the clock command. It was just a quick and >> simple "nice to have" addition. But please, let's get this corrected >> before it starts to be used in so many scripts that we're stuck with >> it until Tcl 10. >> >> >> Schelte. >> >> >> On 24/07/2024 10:04, apnmbx-public--- via Tcl-Core wrote: >>> % clock scan now >>> >>> 1721803544 >>> >>> % clock format now >>> >>> bad seconds "now": must be -now or integer >>> >>> % clock format -now >>> >>> Wed Jul 24 12:16:03 IST 2024 >>> >>> The above seems incongruous to me, why -now for format and “now” for >>> scan? >>> >>> Afaict, “-now” is really a value, not an option. And unlike options, >>> it cannot appear at arbitrary points in the command, only in place of >>> the time value. >>> >>> Is there a rationale for the difference? If no, is it too late to >>> change for 9.0? If too late for compatibility reasons, can clock >>> format and clock add treat “now” and “-now” as synonyms with latter >>> deprecated? (With a TIP of course) >>> >>> /Ashok > > > > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core |