Overview
| Artifact ID: | 1043860b5eb16585eba9b776c16905e17ab9811cb0f95a45adf84fc54e122d0b |
|---|---|
| Ticket: | f4a4bd7f107031f273642cbaefc3cbed72315b1f
lseq "count" argument also dictates output formatting |
| User & Date: | sebres on 2024-08-30 15:31:54 |
Changes
- icomment:
It looks completely fine and desirable to me... Also code says it (I know that exactly, because I touched it as I fixed lseq in [f05f5ef759] and it was pretty obvious intentional). I see it simply as an equivalent of <code><b>lseq</b> ?0 to? <b>3.0</b></code> (further below). <i>>two logically equivalent sequences do not have the same string representation</i> Nothing is here equivalent. Why don't you not wonder that following are different? <code><pre style="padding-left:10pt"> % string compare [expr 3] [expr 3.0] -1 % string compare [expr int(3)] [expr double(3)] -1 </pre></code> I know in your world EIAS, but... the matter of string representation has nothing to do with lseq and completely to neglect here. Most interesting is the question what would happen if the object gets shimmer internally to double. And this can be answered as it'd behave correct. Just because an entier would never shimmer to floating type (because its string representation wouldn't concur for both type). With other words because Tcl_GetDoubleFromObj and co would obtain double from integer without to shimmer: <code><pre style="padding-left:10pt"> % list [set i [expr 3]] [tcl::unsupported::representation $i] 3 {value is a int ...} % lseq $i 0 1 2 % list [expr {double($i)}] [tcl::unsupported::representation $i] 3.0 {value is a int ...} % lseq $i 0 1 2 </pre></code> So shimmering issue is excluded. Nothing else matters. Moreover lseq natively supports expressions, so <code>lseq 3.0</code> is quasi equivalent to <code>lseq [expr {3.0}]</code> and this is also possible (and deliberate): <code><pre style="padding-left:10pt"> % lseq double(3) 0.0 1.0 2.0 </pre></code> <i>> Specially here is clear that the count is an entier:<br/> > % lseq 3.5<br/> > expected integer but got "3.5"</i><br/> It is not clear to me. IMHO, it is simply undefined currently, but easy too fix: To be consistent, I'd rather prefer to change the command so this: <code><pre style="padding-left:10pt"> % lseq 3.0 0.0 1.0 2.0 % lseq 3.5 0.0 1.0 2.0 3.0 # with other words it'd become short equivalent to: % lseq 0 to 3.5 0.0 1.0 2.0 3.0 </pre></code> And documentation can be changed from: <code><pre style="padding-left:10pt"> <b style="color:red">- lseq start ?(..|to)? end ??by? step?</b> <b style="color:green">+ lseq ?start ?(..|to)?? end ??by? step?</b> lseq start count count ??by? step? <b style="color:red">- lseq count ?by step?</b> </pre></code> where start is by default 0 (or 0.0 in case of double end)<br/> It'd be much simpler and more consistent. But it'd be just nice to have. - login: "sebres"
- mimetype: "text/x-fossil-wiki"