Skip to content
Tcl Source Code History Of Ticket f4a4bd7f1070
Login

History Of Ticket f4a4bd7f1070

Artifacts Associated With Ticket f4a4bd7f1070

  1. Ticket change [c0b772ff62] (rid 232016) by pooryorick on 2024-08-29 15:06:16:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      The following interactive session illustrates that two logically equivalent
      sequences do not have the same string representation:
      
      
      <code><verbatim>
      % lseq 3
      0 1 2
      % lseq 3.0
      0.0 1.0 2.0
      % string compare [lseq 3] [lseq 3.0]
      -1
      </verbatim></code>
      
      Overloading the count argument in this way is probably opening a can of worms.
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "ace48c675e6d9823c38a3aa91ffddc0ff84cc79f"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "pooryorick"
    13. subsystem initialized to: "- New Builtin Commands"
    14. title initialized to:
      lseq "count" argument also dictates output formatting
      
    15. type initialized to: "Bug"
  2. Ticket change [28f18bf405] (rid 232017) by jan.nijtmans on 2024-08-29 15:58:21:

    1. closedate changed to: "2460552.16552484"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "This looks like a feature to me, not a bug."
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
  3. Ticket change [cc4a9143d9] (rid 232019) by pooryorick on 2024-08-29 18:41:59:

    1. closer changed to: "nobody"
    2. icomment: "Then it should at least be documented."
    3. login: "pooryorick"
    4. mimetype: "text/x-fossil-wiki"
    5. resolution changed to: "None"
    6. status changed to: "Open"
  4. Ticket change [ee467788a4] (rid 232020) by pooryorick on 2024-08-29 18:44:07:

    1. icomment:
      But overloading parameters like that almost always leads to trouble.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [9137e35ae4] (rid 232026) by oehhar on 2024-08-30 07:37:59:

    1. icomment:
      Dear Nathan, Jan,
      
      please allow me to give my limitted view:
      
      In the form "lseq 3.0" the argument "3.0" is a count for a sequence.
      
      That a coung beeing a float or an entier gives the final format is IMHO "interesting functionality" hard to explain to an end user.
      
      For me, this feels quite critical, as float and entier work quite differently internally. float have roughly 15 significant digits while entier is unlimited.
      
      Specially here is clear that the count is an entier:
      
      <verbatim>
      % lseq 3.5
      expected integer but got "3.5"
      </verbatim>
      
      Controlling the type of the return value is possible by the "by" clause.
      This is logical and ok for me:
      
      <verbatim>
      % lseq 3 by 1
      0 1 2
      % lseq 3 by 1.0
      0.0 1.0 2.0
      </verbatim>
      
      So, I would say, that "lseq 3.0" returning floats is a bug, or at least, a feature hard to explain to the end user. Or do I miss the big picture?
      
      Thank you and take care,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  6. Ticket change [39103e38d4] (rid 232027) by griffin on 2024-08-30 12:26:08:

    1. assignee changed to: "griffin"
    2. icomment:
      I agree, this is not the intended behavior. 
      I think I see where the hole is in the logic.
      
    3. login: "griffin"
    4. mimetype: "text/x-markdown"
  7. Ticket change [1043860b5e] (rid 232028) by sebres on 2024-08-30 15:31:54:

    1. 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.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [8a63e43e83] (rid 232032) by oehhar on 2024-08-30 16:52:40:

    1. icomment:
      Dear Sergey,
      
      thank you for your insights.
      
      The explanation, that:
      
      <verbatim>
      lseq 3.0
      </verbatim>
      is a shortcut for
      <verbatim>
      lseq 0 to 3.0
      </verbatim>
      explains the behaviour.
      If one of the arguments is a float, the mathematics are float and the result is a float.
      
      So, I tried the equivalence:
      <verbatim>
      % lseq 0 to 3.0
      0.0 1.0 2.0 3.0
      % lseq 3.0
      0.0 1.0 2.0
      % lseq 0 to 3.5
      0.0 1.0 2.0 3.0
      </verbatim>
      
      For me, the item "3.0" is missing in the "lseq 3.0" case.
      
      Thank you all for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  9. Ticket change [455e901120] (rid 232033) by pooryorick on 2024-08-30 19:43:18:

    1. icomment:
      This particular report is only about the "count" argument.  At least for that
      option 3 and 3.0 both mean the same thing.  Having "count" always be
      interpreted as a whole number still leaves plenty of room to influence the
      behaviour of [lseq] using the other arguments that it accepts.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [b9d8dbe582] (rid 232035) by apnadkarni on 2024-08-31 05:25:49:

    1. icomment:
      My two cents -
      
      I think the phrase "string representation" in the initial report confused the real issue which is about how a single argument is interpreted.
      
      I tend to agree with Nathan and Harald with the interpretation of a single argument as a count, both because it feels more natural to me and matches current behavior. Sergey's interpretation of a single argument as the "end" (if I read his suggested document change right) subjectively feels less natural and more important would be a change in behavior as Harald points out (lseq 3 would return 4 elements instead of current 3).
      
      If interpreted as a count then, the question remains whether floating values should be accepted if they are whole integers. While it might be mildly convenient for `lseq 100.0` to generate a floating point sequence, for a graph axis e.g.,  I agree that implicitly basing the type of the sequence values on the count argument is not desirable or should at least be documented.
      
      All in all, TL;DR my preference is the single argument to be stay interpreted as a count but only accept integers (not 3.0).
      
      /Ashok
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  11. Ticket change [6ac4d7eeef] (rid 232036) by pooryorick on 2024-08-31 06:09:16:

    1. icomment:
      When behaviour follows meaning, it is intuitive.  3.0 and 3 have the same meaning:
      
      <code><verbatim>
      % expr {3.0 == 3}
      1
      </verbatim></code>
      
      Therefore, prohibiting 3.0 as the value of the count argument would be less
      intuitive and more awkward.  Artificial constraints like that have generally
      been avoided for Tcl.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  12. Ticket change [47de29fe50] (rid 232037) by pooryorick on 2024-08-31 06:25:45:

    1. icomment:
      Following sebres' line of thinking, an alternative would be to eliminate "count" as an argument entirely.  "from", "to", and "by" are probably sufficient.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  13. Ticket change [f0f0092912] (rid 232992) by griffin on 2024-09-01 22:54:57:

    1. closedate changed to: "2460555.45483241"
    2. closer changed to: "griffin"
    3. icomment:
      The numeric type (Integer vs Real) of the Count parameter should not be used to determine the formatting of the results. A Real value can be given as the Count value, but only if the value is a whole number.
      These changes have been implemented in [93057ed877].
      
      As for the other suggestions and critiques, I am very reluctant to change the command argument syntax since this command is already in active use. If the above change impacts any existing applications, it's probably for the better.
      
    4. login: "griffin"
    5. mimetype: "text/x-fossil-plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  14. Ticket change [012fa0a4d5] (rid 233277) by apnadkarni on 2024-09-08 16:55:51:

    1. closedate changed to: "2460562.2054602"
    2. closer changed to: "apnadkarni"
    3. icomment:
      I'll point out this is (I think) the **only** place in Tcl where floating point representations of whole numbers are accepted as counts (or indices for that matter). Consider
      
      ```
      % string repeat x 2.0
      expected integer but got "2.0"
      % lrepeat 2.0 x
      expected integer but got "2.0"
      % # BUT
      % lseq 2.0
      0.0 1.0
      ```
      
      So I'm not sure about the basis for Nathan's comment "*prohibiting 3.0 as the value of the count argument would be less intuitive and more awkward. Artificial constraints like that have generally been avoided for Tcl.*". As seen above, Tcl does in fact have this constraint (artificial or not is a matter of opinion).
      
      As a further aside, also with regards to Nathan's comment, and the `expr 3==3.0` example, compare `expr 1/3` with `expr 1/3.0`. So not sure about the basis for the statement "*3.0 and 3 have the same meaning*" either. At least not in Tcl.
      
      I'd prefer consistency between arguments that are treated as counts (accept floats everywhere or nowhere) but shrug...
      
    4. login: "apnadkarni"
    5. mimetype: "text/x-markdown"
  15. Ticket change [3f618fab8b] (rid 233282) by oehhar on 2024-09-09 09:02:27:

    1. closedate changed to: "2460562.87671281"
    2. closer changed to: "oehhar"
    3. icomment:
      I would be in favor to make this compatible.
      Entier (bignum) and float is really different internally and "entier float" is hard to fullfill in many cases.
      
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/plain"
    6. username: "oehhar"
  16. Ticket change [b72257bcef] (rid 233301) by oehhar on 2024-09-10 12:16:07:

    1. closedate changed to: "2460564.01119986"
    2. icomment:
      Brian said that lseq arguments are expressions on its own.
      This makes the difference, as it is fed to expr.
      
      Thanks,
      Harald
      
    3. login: "oehhar"
    4. mimetype: "text/x-fossil-wiki"
    5. username: "oehhar"