• continue/break function

    From fir@3:633/10 to All on Thu Sep 3 12:19:25 2026
    i slightly returned to coding few days ago
    and when i code i notice little things

    for example i noticed that continue and break in
    function seem to have sense

    for example

    foo()
    {
    int dx = rand2(-1,1);
    int dy = rand2(-1,1);

    if (!dx & !dy) continue;

    // ....
    }
    i mean you want a 9 values, pairs of -1,0,1
    but you dont want 0,0 (thus you want 8 values)

    this continue is handy and simplifies code imo

    as to break, par some kind of analogy you could use
    break and break just would work like return so in some
    way one could said its more natural than return (though it is possibly
    not much strict/fully acurate thesis)

    also i noticed default int from

    foo()
    {
    }

    is not much handy i mean one could say void eventually
    could be better but in fact it seems that this return value should be
    deduced from function body if nt stated explicitely


    fo

    foo() { return 1; } should be int
    and foo() {return 1.0; } should be float

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Thu Sep 3 20:40:44 2026
    On Thu, 3 Sep 2026 12:19:25 +0200, fir wrote:

    for example i noticed that continue and break in function seem to
    have sense

    for example

    foo()
    {
    int dx = rand2(-1,1);
    int dy = rand2(-1,1);

    if (!dx & !dy) continue;

    // ....
    }
    i mean you want a 9 values, pairs of -1,0,1 but you dont want 0,0
    (thus you want 8 values)

    this continue is handy and simplifies code imo

    I?m not sure what it?s supposed to mean, anyway. Where does the
    ?continue? transfer control *to*?

    as to break, par some kind of analogy you could use break and break
    just would work like return so in some way one could said its more
    natural than return ...

    That part I can agree with. I?m not a fan of early returns. If a
    function result was always assigned at the end, then all intermediate
    exits from blocks could be done with break.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Fri Sep 4 19:50:14 2026
    Lawrence D?Oliveiro pisze:
    On Thu, 3 Sep 2026 12:19:25 +0200, fir wrote:

    for example i noticed that continue and break in function seem to
    have sense

    for example

    foo()
    {
    int dx = rand2(-1,1);
    int dy = rand2(-1,1);

    if (!dx & !dy) continue;

    // ....
    }
    i mean you want a 9 values, pairs of -1,0,1 but you dont want 0,0
    (thus you want 8 values)

    this continue is handy and simplifies code imo

    I?m not sure what it?s supposed to mean, anyway. Where does the
    ?continue? transfer control *to*?


    continue jumps to begining of the function

    foo()
    {
    begin:

    //...
    }
    as to break im not sure if this should jump to
    return or just work like return itself
    (i not postulate it, only oticed that continue in
    function body has some utility
    as to break, par some kind of analogy you could use break and break
    just would work like return so in some way one could said its more
    natural than return ...

    That part I can agree with. I?m not a fan of early returns. If a
    function result was always assigned at the end, then all intermediate
    exits from blocks could be done with break.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Fri Sep 4 22:31:03 2026
    On Fri, 4 Sep 2026 19:50:14 +0200, fir wrote:

    Lawrence D?Oliveiro pisze:

    Where does the ?continue? transfer control *to*?

    continue jumps to begining of the function

    Now you have introduced an inconsistency: the body of a function
    behaves like a loop with respect to the interpretation of ?continue?,
    but not otherwise.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)