• Re: Python (was Re: I did not inhale)

    From Kaz Kylheku@643-408-1753@kylheku.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Aug 26 23:32:56 2024
    From Newsgroup: comp.lang.misc

    On 2024-08-26, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    I restore the redundancy by ...

    just standing here?
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 02:49:19 2024
    From Newsgroup: comp.lang.misc

    On Mon, 26 Aug 2024 23:51:40 +0100, Bart wrote:

    This might [...] the human reader but the redundancy really needs to be supported by the language.

    Consider what I mean by “redundancy”: it means the structure of the code is expressed two different ways.

    In a conventional language with statement bracketing symbols, the compiler ignores the indentation, but you use that to delineate the same structure
    as defined by the actual language symbols, thereby providing redundancy to
    the human reader.

    In Python, the compiler goes by the indentation, so I add standins for statement bracketing symbols in the form of “#end” comments: these are ignored by the compiler, but I use that as an alternative, redundant way
    of delineating the same program structure to the human reader.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 02:50:41 2024
    From Newsgroup: comp.lang.misc

    On Mon, 26 Aug 2024 15:51:13 -0700, John Ames wrote:

    if condition:
    foo()

    bar()

    baz()

    if one needs to re-arrange the order of operations, for reasons, and one
    is incautious about selecting and shuffling lines in one's editor, such
    that one ends up with this:

    if condition:
    bar()

    foo()

    baz()

    Try:

    if condition:
    foo()
    bar()
    #end if
    baz()

    versus

    if condition:
    bar()
    foo()
    #end if
    baz()

    Does that make things clearer?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Sebastian@sebastian@here.com.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 03:21:28 2024
    From Newsgroup: comp.lang.misc

    In comp.unix.programmer John Ames <commodorejohn@gmail.com> wrote:
    On Mon, 26 Aug 2024 21:35:25 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    I restore the redundancy by using ?#end? comments. E.g. a seriously
    nontrivial case:

    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in tab/space factor between $EDITOR and the Python RTE, which is a truly ridiculous thing to have to be concerned about.

    (Thing I'm curious about, but don't have a test environment to hand -
    does a blank line with a different indent level, in between lines of
    the same level, break out of the block? E.g., given the following:

    if condition:
    foo()

    bar()

    baz()

    The answer is that it doesn't matter if the blank line between foo() and
    bar() contains four spaces. bar() will always be treated as being part
    of the if statement's body.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Richard Kettlewell@invalid@invalid.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 09:39:29 2024
    From Newsgroup: comp.lang.misc

    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in tab/space factor between $EDITOR and the Python RTE, which is a truly ridiculous thing to have to be concerned about.

    In many years of using Python routinely and extensively I’ve simply
    never found the whitespace issues that people are worrying about here to
    be a problem in practice. Some of this may be a matter of experience but
    if so, it’s a form of experience that must have built up very quickly.

    As an aesthetic objection, of course, there’s no accounting for
    taste. But it doesn’t seem to be a practical problem in reality.

    (In contrast C’s rules have occasionally been a practical problem, contributing to at least one high-profile software vulnerability and
    attracting compiler warnings to mitigate the risks.)
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 11:26:18 2024
    From Newsgroup: comp.lang.misc

    On 27/08/2024 09:39, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in
    tab/space factor between $EDITOR and the Python RTE, which is a truly
    ridiculous thing to have to be concerned about.

    In many years of using Python routinely and extensively I’ve simply
    never found the whitespace issues that people are worrying about here to
    be a problem in practice. Some of this may be a matter of experience but
    if so, it’s a form of experience that must have built up very quickly.

    As an aesthetic objection, of course, there’s no accounting for
    taste. But it doesn’t seem to be a practical problem in reality.

    (In contrast C’s rules have occasionally been a practical problem, contributing to at least one high-profile software vulnerability and attracting compiler warnings to mitigate the risks.)

    These are the problems I've seen. I haven't used the language
    extensively, but I've used it enough.

    (1) An tab at the start of a line gets accidentally indented or
    unindented. If you weren't paying close attention, it may not be clear
    that that has happened, if this line was either the last line of an
    indented block, or the line following

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block. And, also the block then merges with the
    following one as it's at the same level, so when you want to change it
    back...

    (3) Similarly, you want to temportarily wrap an 'if' statement, for
    example, around a block of code. But you can't do it witout indenting
    that block.

    (4) Sometimes you want to add temporary debug code as part of a block.
    Usually I write such lines in all-caps and without indentation to make
    them stand out clear. With Python, I can't use all-caps and I have to
    use exactly the same indent as the rest of the block. So the lines
    merge. Then when I need to remove the code, it's not clearly delimited.

    (5) Sometimes you want to temporarily comment out the contents of a
    block. But Python doesn't allow an empty block; now you have to use
    'pass'. And then get rid of if later.

    (6) You want to add extra statements to the end of a block, but where IS
    the end? You have to INFER the ending by looking for a line with a
    smaller indent. But suppose you're at the bottom of a window; is that
    bottom line the last in the block, or is there another one at the same
    indent just out of sight? You have to tentatively keep peeking ahead!

    (6a) And maybe there's big comment blocking in the middle of block;
    comments don't need nesting! If there are lots of comments and few
    statements, finding the end of the block (ie. the last statement of this block) can become quite an exercise.

    (7) You take some Python code you've seen online (eg. in a usenet post)
    and paste into your editor. Maybe you want to merge it with your own code.

    But its tabbing is all spaces; yours is all tabs. Plus invariably, the
    whole thing has extra indentation (eg. the leftmost statement is already indented). Or you want to copy code from within a block to a different
    indent level.

    The whole thing gets very messy and error prone. You need special editor commands to deal with the mess.

    Indented, non-delimited code and data is fine for machine-generated and machine processed code. But it's a disaster for code that has to be human-generated and human-maintained. It's just too fragile.

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.




    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Richard Kettlewell@invalid@invalid.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 13:46:36 2024
    From Newsgroup: comp.lang.misc

    Bart <bc@freeuk.com> writes:
    On 27/08/2024 09:39, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in
    tab/space factor between $EDITOR and the Python RTE, which is a truly
    ridiculous thing to have to be concerned about.
    In many years of using Python routinely and extensively I’ve simply
    never found the whitespace issues that people are worrying about here to
    be a problem in practice. Some of this may be a matter of experience but
    if so, it’s a form of experience that must have built up very quickly.
    As an aesthetic objection, of course, there’s no accounting for
    taste. But it doesn’t seem to be a practical problem in reality.
    (In contrast C’s rules have occasionally been a practical problem,
    contributing to at least one high-profile software vulnerability and
    attracting compiler warnings to mitigate the risks.)

    These are the problems I've seen. I haven't used the language
    extensively, but I've used it enough.

    All I can say is that for the most part these issues just don’t arise
    for me. Some are plainly aesthetic; I already addressed that. Others
    sounds like issues with your tooling - changing the indentation of a
    range of lines is easy in most editors, for example.

    The cases that actually seem familiar:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block. And, also the block then merges with the
    following one as it's at the same level, so when you want to change it back...

    You can put ‘or True’ at the end of the condition.

    (5) Sometimes you want to temporarily comment out the contents of a
    block. But Python doesn't allow an empty block; now you have to use
    'pass'. And then get rid of if later.

    You can put an ‘if False’ at the top.

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.

    I’ve never encountered anyone else doing that in Python. It suggests
    more than the individual doing that just doesn’t like the language, in
    which case I’d just suggest that person doesn’t use it.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 15:10:08 2024
    From Newsgroup: comp.lang.misc

    On 27/08/2024 12:26, Bart wrote:
    On 27/08/2024 09:39, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in
    tab/space factor between $EDITOR and the Python RTE, which is a truly
    ridiculous thing to have to be concerned about.

    In many years of using Python routinely and extensively I’ve simply
    never found the whitespace issues that people are worrying about here to
    be a problem in practice. Some of this may be a matter of experience but
    if so, it’s a form of experience that must have built up very quickly.


    I have occasionally, but only occasionally, seen problems with white
    space. And those would normally be caught by Python 3.

    As an aesthetic objection, of course, there’s no accounting for
    taste. But it doesn’t seem to be a practical problem in reality.

    (In contrast C’s rules have occasionally been a practical problem,
    contributing to at least one high-profile software vulnerability and
    attracting compiler warnings to mitigate the risks.)

    These are the problems I've seen. I haven't used the language
    extensively, but I've used it enough.

    Your problems below are all valid, but not insurmountable. I too would
    rather have explicit block delimiters, but it's not actually hard to
    work with Python as it is.


    (1) An tab at the start of a line gets accidentally indented or
    unindented. If you weren't paying close attention, it may not be clear
    that that has happened, if this line was either the last line of an
    indented block, or the line following


    That /can/ happen. It is a good idea to avoid mixing tabs and spaces in
    the same file. Most editors can be configured one way or the other, but
    if you use different editors under different circumstances (as I do),
    mistakes are possible. They are usually quickly identified and quickly handled.

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block. And, also  the block then merges with the
    following one as it's at the same level, so when you want to change it back...

    Replace your

    if cond :

    with

    if 1 :

    or

    if True :



    (3) Similarly, you want to temportarily wrap an 'if' statement, for
    example, around a block of code. But you can't do it witout indenting
    that block.


    True. But any editor will let you select the lines and indent them.

    (4) Sometimes you want to add temporary debug code as part of a block. Usually I write such lines in all-caps and without indentation to make
    them stand out clear. With Python, I can't use all-caps and I have to
    use exactly the same indent as the rest of the block. So the lines
    merge. Then when I need to remove the code, it's not clearly delimited.

    Comments are an extremely easy way to make the code stand out.


    (5) Sometimes you want to temporarily comment out the contents of a
    block. But Python doesn't allow an empty block; now you have to use
    'pass'. And then get rid of if later.

    You can leave the "pass" in, if you don't want to get ride of it later.
    I sometimes find "pass" to be helpful as an alternative to leaving a
    hanging indented block.


    (6) You want to add extra statements to the end of a block, but where IS
    the end? You have to INFER the ending by looking for a line with a
    smaller indent. But suppose you're at the bottom of a window; is that
    bottom line the last in the block, or is there another one at the same indent just out of sight? You have to tentatively keep peeking ahead!

    Keep your blocks small and neat.


    (6a) And maybe there's big comment blocking in the middle of block;
    comments don't need nesting! If there are lots of comments and few statements, finding the end of the block (ie. the last statement of this block) can become quite an exercise.

    That applies to every programming language (unless you know of one that doesn't support comments).


    (7) You take some Python code you've seen online (eg. in a usenet post)
    and paste into your editor. Maybe you want to merge it with your own code.

    But its tabbing is all spaces; yours is all tabs. Plus invariably, the
    whole thing has extra indentation (eg. the leftmost statement is already indented). Or you want to copy code from within a block to a different indent level.

    Any sane editor will give you tools to fix that - automatic indentation, tab-to-space and space-to-tab conversion, manual indent or outdent block tools, etc.


    The whole thing gets very messy and error prone. You need special editor commands to deal with the mess.

    No, you don't. (Unless you think "special" means "anything but Windows Notepad" .)


    Indented, non-delimited code and data is fine for machine-generated and machine processed code. But it's a disaster for code that has to be human-generated and human-maintained. It's just too fragile.


    In real-life Python coding, it works fine. I prefer explicit block delimiters, but I cannot say Python's white-space blocking has been a significant source of trouble or inconvenience for me. Perhaps that's
    because I have always been used to careful and consistent formatting. I
    don't write C code (or any other code) with inconsistent spacing, mixes
    of tabs and spaces, or unexpected indentations. So for me, the spacing
    and tabbing of Python code would be identical if it had braces or other begin-end markers.

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.


    No one has to do that. It's a Lawrence peculiarity, and his coding
    style (in Python or C, and probably anything else) would be rejected by
    anyone with a coding standard. I agree that it suggests that something
    is badly wrong, but it is not with the language!


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 15:18:47 2024
    From Newsgroup: comp.lang.misc

    On 27/08/2024 14:10, David Brown wrote:
    On 27/08/2024 12:26, Bart wrote:
    On 27/08/2024 09:39, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues >>>> of the interpreter potentially mis-parsing things due to mismatches in >>>> tab/space factor between $EDITOR and the Python RTE, which is a truly
    ridiculous thing to have to be concerned about.

    In many years of using Python routinely and extensively I’ve simply
    never found the whitespace issues that people are worrying about here to >>> be a problem in practice. Some of this may be a matter of experience but >>> if so, it’s a form of experience that must have built up very quickly. >>>

    I have occasionally, but only occasionally, seen problems with white space.  And those would normally be caught by Python 3.

    As an aesthetic objection, of course, there’s no accounting for
    taste. But it doesn’t seem to be a practical problem in reality.

    (In contrast C’s rules have occasionally been a practical problem,
    contributing to at least one high-profile software vulnerability and
    attracting compiler warnings to mitigate the risks.)

    These are the problems I've seen. I haven't used the language
    extensively, but I've used it enough.

    Your problems below are all valid, but not insurmountable.  I too would rather have explicit block delimiters, but it's not actually hard to
    work with Python as it is.


    (1) An tab at the start of a line gets accidentally indented or
    unindented. If you weren't paying close attention, it may not be clear
    that that has happened, if this line was either the last line of an
    indented block, or the line following


    That /can/ happen.  It is a good idea to avoid mixing tabs and spaces in the same file.  Most editors can be configured one way or the other, but
    if you use different editors under different circumstances (as I do), mistakes are possible.  They are usually quickly identified and quickly handled.

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block. And, also  the block then merges with the
    following one as it's at the same level, so when you want to change it
    back...

    Replace your

        if cond :

    with

        if 1 :

    or

        if True :



    (3) Similarly, you want to temportarily wrap an 'if' statement, for
    example, around a block of code. But you can't do it witout indenting
    that block.


    True.  But any editor will let you select the lines and indent them.

    (4) Sometimes you want to add temporary debug code as part of a block.
    Usually I write such lines in all-caps and without indentation to make
    them stand out clear. With Python, I can't use all-caps and I have to
    use exactly the same indent as the rest of the block. So the lines
    merge. Then when I need to remove the code, it's not clearly delimited.

    Comments are an extremely easy way to make the code stand out.


    (5) Sometimes you want to temporarily comment out the contents of a
    block. But Python doesn't allow an empty block; now you have to use
    'pass'. And then get rid of if later.

    You can leave the "pass" in, if you don't want to get ride of it later.
    I sometimes find "pass" to be helpful as an alternative to leaving a
    hanging indented block.


    (6) You want to add extra statements to the end of a block, but where
    IS the end? You have to INFER the ending by looking for a line with a
    smaller indent. But suppose you're at the bottom of a window; is that
    bottom line the last in the block, or is there another one at the same
    indent just out of sight? You have to tentatively keep peeking ahead!

    Keep your blocks small and neat.


    (6a) And maybe there's big comment blocking in the middle of block;
    comments don't need nesting! If there are lots of comments and few
    statements, finding the end of the block (ie. the last statement of
    this block) can become quite an exercise.

    That applies to every programming language (unless you know of one that doesn't support comments).


    (7) You take some Python code you've seen online (eg. in a usenet
    post) and paste into your editor. Maybe you want to merge it with your
    own code.

    But its tabbing is all spaces; yours is all tabs. Plus invariably, the
    whole thing has extra indentation (eg. the leftmost statement is
    already indented). Or you want to copy code from within a block to a
    different indent level.

    Any sane editor will give you tools to fix that - automatic indentation, tab-to-space and space-to-tab conversion, manual indent or outdent block tools, etc.


    The whole thing gets very messy and error prone. You need special
    editor commands to deal with the mess.

    No, you don't.  (Unless you think "special" means "anything but Windows Notepad" .)


    Indented, non-delimited code and data is fine for machine-generated
    and machine processed code. But it's a disaster for code that has to
    be human-generated and human-maintained. It's just too fragile.


    In real-life Python coding, it works fine.  I prefer explicit block delimiters, but I cannot say Python's white-space blocking has been a significant source of trouble or inconvenience for me.  Perhaps that's because I have always been used to careful and consistent formatting.  I don't write C code (or any other code) with inconsistent spacing, mixes
    of tabs and spaces, or unexpected indentations.  So for me, the spacing
    and tabbing of Python code would be identical if it had braces or other begin-end markers.

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.


    No one has to do that.  It's a Lawrence peculiarity, and his coding
    style (in Python or C, and probably anything else) would be rejected by anyone with a coding standard.  I agree that it suggests that something
    is badly wrong, but it is not with the language!

    It's not just him. Below is some Nim code, which uses indentation like
    Python. (It's from inside other statements which accounts for the
    overall indents.)

    Suppose I want to add code to follow that top-level 'if' statement;
    where would it go? Since it's not clear from my extract whether that's
    the entire content of my if statement.

    And at what indent level, since I'm some way off from that if? It's easy
    to get it wrong.

    if q1!=1:
    for i in countup(2,n):
    q[i]=p[i]
    flips=1
    while true:
    qq=q[q1]
    if qq==1:
    sum+=sign*flips
    if flips>maxflips:
    maxflips=flips
    break
    q[q1]=q1
    if q1>=4:
    i=2
    j=q1-1
    while true:
    t=q[i]
    q[i]=q[j]
    q[j]=t
    i+=1
    j-=1
    if i>=j:
    break
    q1=qq
    flips+=1

    This was an attempt to port an benchmark into Nim; I'd spent the best
    part of an hour trying to get it right, but it kept going wrong. In the
    end I resorted to artificial block terminators.

    The final code looked like that below. Now it is much, much easier to
    see what goes where, and what belongs to what. I can more confidently
    write that extra statement following the opening 'if'.

    With these changes, the porting went much more smooothly.

    if q1!=1:
    for i in countup(2,n):
    q[i]=p[i]
    # end
    flips=1
    while true:
    qq=q[q1]
    if qq==1:
    sum+=sign*flips
    if flips>maxflips:
    maxflips=flips
    # end
    break
    # end
    q[q1]=q1
    if q1>=4:
    i=2
    j=q1-1
    while true:
    t=q[i]
    q[i]=q[j]
    q[j]=t
    i+=1
    j-=1
    if i>=j:
    break
    # end
    # end
    # end
    q1=qq
    flips+=1
    # end
    # end


    Sure, people CAN program in such languages, but it is harder work and
    more error prone.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From John Ames@commodorejohn@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 08:03:20 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 15:10:08 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    (6) You want to add extra statements to the end of a block, but
    where IS the end? You have to INFER the ending by looking for a
    line with a smaller indent. But suppose you're at the bottom of a
    window; is that bottom line the last in the block, or is there
    another one at the same indent just out of sight? You have to
    tentatively keep peeking ahead!

    Keep your blocks small and neat.

    That's very much one for the "good advice that is not always feasible
    in the Real World" file. Every project has its own natural balance of
    "large things that can be easily re-factored into sets of small things"
    (i.e. things you can function-ize) vs. "large things that cannot."

    (6a) And maybe there's big comment blocking in the middle of block; comments don't need nesting! If there are lots of comments and few statements, finding the end of the block (ie. the last statement of
    this block) can become quite an exercise.

    That applies to every programming language (unless you know of one
    that doesn't support comments).

    It applies very much moreso to languages where comments *must* follow
    the indentation level of the surrounding code, so that the deeper you
    go, the more lines you have to split comments across.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 18:08:22 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 08:03:20 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    It applies very much moreso to languages where comments *must* follow
    the indentation level of the surrounding code, so that the deeper you
    go, the more lines you have to split comments across.

    Unless you're one of those developers for whom breaking up lines is a foreign concept and you just continue on a single line until you're done no matter
    how long it is.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 20:46:27 2024
    From Newsgroup: comp.lang.misc

    On 27/08/2024 17:03, John Ames wrote:
    On Tue, 27 Aug 2024 15:10:08 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    (6) You want to add extra statements to the end of a block, but
    where IS the end? You have to INFER the ending by looking for a
    line with a smaller indent. But suppose you're at the bottom of a
    window; is that bottom line the last in the block, or is there
    another one at the same indent just out of sight? You have to
    tentatively keep peeking ahead!

    Keep your blocks small and neat.

    That's very much one for the "good advice that is not always feasible
    in the Real World" file. Every project has its own natural balance of
    "large things that can be easily re-factored into sets of small things"
    (i.e. things you can function-ize) vs. "large things that cannot."


    Sure. But if you keep such advice at hand, then it is often easier to
    make it feasible. Occasionally code is best formatted with a big
    function or two, but most of the time it is possible and preferable to
    have relatively small function.

    (6a) And maybe there's big comment blocking in the middle of block;
    comments don't need nesting! If there are lots of comments and few
    statements, finding the end of the block (ie. the last statement of
    this block) can become quite an exercise.

    That applies to every programming language (unless you know of one
    that doesn't support comments).

    It applies very much moreso to languages where comments *must* follow
    the indentation level of the surrounding code, so that the deeper you
    go, the more lines you have to split comments across.


    It is not common to have to have indent comment lines (certainly in
    Python it is not necessary). And if you find yourself writing large
    comments in the middle of a block in the middle of a function, it is
    probably time to consider re-organising the code and/or the comments and documentation. (Again, there can be exceptions to this general rule.)

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 21:34:54 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    And, also the block then merges with the
    following one as it's at the same level, so when you want to change it back...

    This is where my “#end” comments come in.

    (6a) And maybe there's big comment blocking in the middle of block;
    comments don't need nesting! If there are lots of comments and few statements, finding the end of the block (ie. the last statement of this block) can become quite an exercise.

    Again, “#end” comments help with this.

    (7) You take some Python code you've seen online (eg. in a usenet post)
    and paste into your editor. Maybe you want to merge it with your own
    code.

    But its tabbing is all spaces; yours is all tabs. Plus invariably, the
    whole thing has extra indentation (eg. the leftmost statement is already indented). Or you want to copy code from within a block to a different
    indent level.

    Like I said, Emacs makes this easy. Also a quick application of “untabify” will turn all tabs in the selected region to spaces, to match with the
    rest of my code.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 21:40:19 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 20:46:27 +0200, David Brown wrote:

    It is not common to have to have indent comment lines (certainly in
    Python it is not necessary). And if you find yourself writing large
    comments in the middle of a block in the middle of a function, it is
    probably time to consider re-organising the code and/or the comments and documentation. (Again, there can be exceptions to this general rule.)

    Counterexample: <https://www.cairographics.org/cookbook/freetypepython/>
    (Yes, that’s one of mine). Note the explanation of the user-data dance,
    for backward compatibility with older FreeType. Where else would you put
    the comments, if not next to the code they’re explaining?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 14:49:19 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:
    [...]
    And, also the block then merges with the
    following one as it's at the same level, so when you want to change it
    back...

    This is where my “#end” comments come in.
    [...]

    It's worth noting that you're the only person I've ever heard of
    who feels the need to do this. People here who aren't familiar
    with Python should be aware that this is not common practice.

    I've done some Python programming, and it wouldn't occur to me to
    add "#end" comments. If I saw them in a code review I'd probably
    recommend deleting them. I prefer to approach each language on
    its own terms. (I happen to like the way Python uses semantically
    significant indentation, but even if I didn't I'd still do the same.)

    In brace-delimited languages (C, C++, Perl, etc.), I'm very careful
    to keep the indentation consistent with the program structure.
    I do the same in Python. The difference is that in Python the
    indentation is the single source of truth about program structure,
    while in other languages it's a matter of convention.

    https://en.wikipedia.org/wiki/Single_source_of_truth

    As for tabs vs. spaces, my understanding is that recent versions
    of Perl allow mixing them (something I avoid), but if the meaning
    can change depending on the size of a tabstop the code is rejected.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 23:28:18 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 14:49:19 -0700, Keith Thompson wrote:

    I've done some Python programming, and it wouldn't occur to me to add
    "#end" comments. If I saw them in a code review I'd probably recommend deleting them.

    Give them a try. They simplify a lot of situations. I already posted a reasonably complex example in this thread. Go have a look at it, and see
    what happens when you delete those comments.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Aug 27 19:10:57 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Tue, 27 Aug 2024 14:49:19 -0700, Keith Thompson wrote:
    I've done some Python programming, and it wouldn't occur to me to add
    "#end" comments. If I saw them in a code review I'd probably recommend
    deleting them.

    Give them a try. They simplify a lot of situations. I already posted a reasonably complex example in this thread. Go have a look at it, and see what happens when you delete those comments.

    No, I won't be doing that.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Sebastian@sebastian@here.com.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 02:48:59 2024
    From Newsgroup: comp.lang.misc

    In comp.unix.programmer Richard Kettlewell <invalid@invalid.invalid> wrote:
    John Ames <commodorejohn@gmail.com> writes:
    But even if that helps you organizationally, it doesn't resolve issues
    of the interpreter potentially mis-parsing things due to mismatches in
    tab/space factor between $EDITOR and the Python RTE, which is a truly
    ridiculous thing to have to be concerned about.

    In many years of using Python routinely and extensively I?ve simply
    never found the whitespace issues that people are worrying about here to
    be a problem in practice. Some of this may be a matter of experience but
    if so, it?s a form of experience that must have built up very quickly.

    I've seen bugs in production that are due to Python's indentation rules. Consider this class:

    class Foo:
    def method1(self):
    call1()
    call2()
    call3()

    def method2(self):
    call4()
    if some_condition:
    with some_object() as o:
    call5()
    # hundreds of other lines of code
    call6()

    At my company, somebody tried to delete a method like method2() above,
    but forgot the last few lines (represented by call6()). This does
    not introduce a SyntaxError. Instead, call6() is now part of method1()
    because it's at the same level of indentation. In most programming
    languages, the beginning of method2() would be preceded by some delimiter marking the end of method1(), which would prevent an accidental merger
    of this type.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Sebastian@sebastian@here.com.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 02:53:41 2024
    From Newsgroup: comp.lang.misc

    In comp.unix.programmer Richard Kettlewell <invalid@invalid.invalid> wrote:
    Bart <bc@freeuk.com> writes:
    On 27/08/2024 09:39, Richard Kettlewell wrote:

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.

    I?ve never encountered anyone else doing that in Python. It suggests
    more than the individual doing that just doesn?t like the language, in
    which case I?d just suggest that person doesn?t use it.

    I think it's a great idea. I'm considering asking my team to start adding
    #end comments to our codebase.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Sebastian@sebastian@here.com.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 03:19:07 2024
    From Newsgroup: comp.lang.misc

    In comp.unix.programmer David Brown <david.brown@hesbynett.no> wrote:

    It is not common to have to have indent comment lines (certainly in
    Python it is not necessary). And if you find yourself writing large comments in the middle of a block in the middle of a function, it is probably time to consider re-organising the code and/or the comments and documentation. (Again, there can be exceptions to this general rule.)


    It may not be "common" (ie, not a lot of languages have this requirement),
    but if it's your job to maintain a project written in such a language,
    then you'll have to deal with that problem every single day.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 05:30:31 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 19:10:57 -0700, Keith Thompson wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 14:49:19 -0700, Keith Thompson wrote:

    I've done some Python programming, and it wouldn't occur to me to add
    "#end" comments. If I saw them in a code review I'd probably
    recommend deleting them.

    Give them a try. They simplify a lot of situations. I already posted a
    reasonably complex example in this thread. Go have a look at it, and
    see what happens when you delete those comments.

    No, I won't be doing that.

    I wonder why? You expressed an opinion about them, yet when I try to find
    out more about why you feel that way, you run away.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 12:45:40 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 05:19, Sebastian wrote:
    In comp.unix.programmer David Brown <david.brown@hesbynett.no> wrote:

    It is not common to have to have indent comment lines (certainly in
    Python it is not necessary). And if you find yourself writing large
    comments in the middle of a block in the middle of a function, it is
    probably time to consider re-organising the code and/or the comments and
    documentation. (Again, there can be exceptions to this general rule.)


    It may not be "common" (ie, not a lot of languages have this requirement), but if it's your job to maintain a project written in such a language,
    then you'll have to deal with that problem every single day.

    If you have some code that needs a lot of documentation (and some does),
    then put the comments in a place that does not interfere with reading
    and understanding the code. Comments that make code harder to read are counter-productive.

    Where these comments end up - elsewhere in the function, outside the
    function, at the head of the file, in a separate file, in completely
    separate documentation - depends on the situation.



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 13:57:11 2024
    From Newsgroup: comp.lang.misc

    Sebastian <sebastian@here.com.invalid> writes:
    In comp.unix.programmer Richard Kettlewell <invalid@invalid.invalid> wrote:
    Bart <bc@freeuk.com> writes:
    On 27/08/2024 09:39, Richard Kettlewell wrote:

    The fact that people have to resort to adding #end lines, which only
    partly deals with one or two of those problems, suggest that something
    is badly wrong.

    I?ve never encountered anyone else doing that in Python. It suggests
    more than the individual doing that just doesn?t like the language, in
    which case I?d just suggest that person doesn?t use it.

    I think it's a great idea. I'm considering asking my team to start adding >#end comments to our codebase.

    I think you're a L'D'O sockpuppet.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From John Ames@commodorejohn@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 08:25:21 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 02:48:59 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> wrote:

    At my company, somebody tried to delete a method like method2() above,
    but forgot the last few lines (represented by call6()). This does
    not introduce a SyntaxError. Instead, call6() is now part of method1() because it's at the same level of indentation. In most programming
    languages, the beginning of method2() would be preceded by some
    delimiter marking the end of method1(), which would prevent an
    accidental merger of this type.

    (Waiting for the Python advocates to fire back with "well, don't do
    that, then!" and completely miss the point that it's exactly the topic
    of contention here that Python's scope-by-layout approach that makes it
    easy to do that...)

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 16:41:07 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 16:25, John Ames wrote:
    On Wed, 28 Aug 2024 02:48:59 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> wrote:

    At my company, somebody tried to delete a method like method2() above,
    but forgot the last few lines (represented by call6()). This does
    not introduce a SyntaxError. Instead, call6() is now part of method1()
    because it's at the same level of indentation. In most programming
    languages, the beginning of method2() would be preceded by some
    delimiter marking the end of method1(), which would prevent an
    accidental merger of this type.

    (Waiting for the Python advocates to fire back with "well, don't do
    that, then!" and completely miss the point that it's exactly the topic
    of contention here that Python's scope-by-layout approach that makes it
    easy to do that...)


    Or they will say that whoever deleted method2 could also have deleted
    that 'end' line if one was used. Whilst also forgetting to delete
    method2's own 'end' line.

    Or maybe they deleted method2 plus both the preceding and succeeding
    lines so that method1 merges into method3.

    Generally, they might point all the ways that such oversights and all
    kinds of other typos can result in still-valid code in any language. But fragile syntax like Python's just makes it so easier to do that.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Richard Kettlewell@invalid@invalid.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 16:41:36 2024
    From Newsgroup: comp.lang.misc

    John Ames <commodorejohn@gmail.com> writes:
    Sebastian <sebastian@here.com.invalid> wrote:

    At my company, somebody tried to delete a method like method2()
    above, but forgot the last few lines (represented by call6()). This
    does not introduce a SyntaxError. Instead, call6() is now part of
    method1() because it's at the same level of indentation. In most
    programming languages, the beginning of method2() would be preceded
    by some delimiter marking the end of method1(), which would prevent
    an accidental merger of this type.

    (Waiting for the Python advocates to fire back with "well, don't do
    that, then!" and completely miss the point that it's exactly the topic
    of contention here that Python's scope-by-layout approach that makes it
    easy to do that...)

    Earlier I wrote:

    | (In contrast C’s rules have occasionally been a practical problem,
    | contributing to at least one high-profile software vulnerability and
    | attracting compiler warnings to mitigate the risks.)

    The situation seems pretty similar. In any language if you delete the
    wrong thing then you probably won’t like the outcome. In both cases if
    it’s not quickly detected by unit tests or some other automation then
    it’s probably time to review your approach to quality.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 18:23:31 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 17:41, Bart wrote:
    On 28/08/2024 16:25, John Ames wrote:
    On Wed, 28 Aug 2024 02:48:59 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> wrote:

    At my company, somebody tried to delete a method like method2() above,
    but forgot the last few lines (represented by call6()). This does
    not introduce a SyntaxError. Instead, call6() is now part of method1()
    because it's at the same level of indentation. In most programming
    languages, the beginning of method2() would be preceded by some
    delimiter marking the end of method1(), which would prevent an
    accidental merger of this type.

    (Waiting for the Python advocates to fire back with "well, don't do
    that, then!" and completely miss the point that it's exactly the topic
    of contention here that Python's scope-by-layout approach that makes it
    easy to do that...)


    Or they will say that whoever deleted method2 could also have deleted
    that 'end' line if one was used. Whilst also forgetting to delete
    method2's own 'end' line.

    Or maybe they deleted method2 plus both the preceding and succeeding
    lines so that method1 merges into method3.

    Generally, they might point all the ways that such oversights and all
    kinds of other typos can result in still-valid code in any language. But fragile syntax like Python's just makes it so easier to do that.


    Having overly-large functions in any language is a risky way to code.
    Deleting large chunks of a function is risky in any language. Failing
    to have check in place (like automated tests) that catch the error
    fairly quickly is also risky in any language.

    But it is fair to say, I think, that Python's space-sensitive syntax
    combined with limited static checking (even with tools like pylint) mean
    you are more likely to be able to make a mistake that is not spotted
    until later in testing, compared to languages with explicit block
    delimiters.

    And it is made worse by Python common practice of defining all methods
    of a class inline in the class, leading to long stretches of code that
    is all indented at least one tabstop. It is possible to add methods to
    a class later on - optionally after giving a placeholder, but it is not
    common practice (as far as I have seen) :

    class A :
    def __init__(self) :
    self.x = 10
    def foo(self) :
    "Increment x"
    self.x = self.x + 1
    return self.x
    def foobar(self) :
    "Complicated action"
    raise NotImplementedError

    def A_foobar(self) :
    self.x = self.x * 10
    return self.x

    A.foobar = A_foobar


    (I'm sure a decorator could be used to make this slightly neater.)




    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 17:43:44 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad language design is not something a programmer should have to waste time on.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 17:48:57 2024
    From Newsgroup: comp.lang.misc

    On Tue, 27 Aug 2024 14:49:19 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    I do the same in Python. The difference is that in Python the
    indentation is the single source of truth about program structure,

    Sadly.

    while in other languages it's a matter of convention.

    https://en.wikipedia.org/wiki/Single_source_of_truth

    That reads like the sort of pseudo philosphical gasbagging beloved of a certain type of ivory tower university lecturer who would probably last 2 days in a commercial IT enviroment.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 20:48:08 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad language design is not something a programmer should have to waste time on.



    I don't know about Emacs, but in most editors the way you indent a block
    of code is to select the lines, then press "Tab". Unindenting is
    "shift-Tab". Changing tabs to spaces or spaces to tabs is done by
    selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious. Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type (so
    you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet still
    have trouble with this kind of thing.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 20:27:53 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 19:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste
    time on.



    I don't know about Emacs, but in most editors the way you indent a block
    of code is to select the lines, then press "Tab".  Unindenting is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done by selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious.  Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type (so
    you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet still
    have trouble with this kind of thing.

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design. A lesser one
    is having to rely on whatever varied features that 100s of different
    editors may have to do so.

    And yet another, of more significance, if that after you've indented a
    block, it may now merge into an adjacent block that was already at that
    new indent. If you later need to revert that first block back to it's
    original position, you'd better make sure you mark that boundary.

    It is a language design issue pure and simple. Don't try and pin it on
    the users and make out it's due to lack of expertise with their editors.
    Of course we can all indent blocks; it's just an unnecessary palaver.

    Clearly your point of view is as a language /user/ where languages and
    their characteristics are an invariant that you can't do anything about,
    can't change, and need to work around.

    But some of us devise (and, importanly, implement) languages of our own
    and can be more vocal about misfeatures in others.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 13:29:18 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Tue, 27 Aug 2024 19:10:57 -0700, Keith Thompson wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Tue, 27 Aug 2024 14:49:19 -0700, Keith Thompson wrote:
    I've done some Python programming, and it wouldn't occur to me to add
    "#end" comments. If I saw them in a code review I'd probably
    recommend deleting them.

    Give them a try. They simplify a lot of situations. I already posted a
    reasonably complex example in this thread. Go have a look at it, and
    see what happens when you delete those comments.

    No, I won't be doing that.

    I wonder why? You expressed an opinion about them, yet when I try to find out more about why you feel that way, you run away.

    I didn't intend to run away, I was just declining to engage.

    But ok, I found your post and removed all the #end comments. I found it
    just as readable without them as with them.

    I'm very much aware that different people perceive things differently.
    (An unrelated example: I find "Yoda conditions" like `if (42 == value)`
    deeply annoying, but some people like them.) If #end comments help you,
    I'm not going to tell you not to use them. But be aware that (a) other
    readers might dislike them, and (b) if you're going to be reading Python
    code written by others, you'll need to be able to get along without
    them.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 13:37:24 2024
    From Newsgroup: comp.lang.misc

    Bart <bc@freeuk.com> writes:
    On 28/08/2024 19:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste
    time on.


    I don't know about Emacs, but in most editors the way you indent a
    block of code is to select the lines, then press "Tab".  Unindenting
    is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done
    by selecting "Tabs to spaces" from the Edit menu, or something
    equally simple and obvious.  Many editor can be set to convert tabs
    to spaces (or vice versa) when saving files, perhaps specific to the
    file type (so you don't muck up your makefiles).
    It takes a special kind of genius to be able to program, and yet
    still have trouble with this kind of thing.

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design. A lesser one
    is having to rely on whatever varied features that 100s of different
    editors may have to do so.

    And yet another, of more significance, if that after you've indented a
    block, it may now merge into an adjacent block that was already at
    that new indent. If you later need to revert that first block back to
    it's original position, you'd better make sure you mark that boundary.

    It is a language design issue pure and simple. Don't try and pin it on
    the users and make out it's due to lack of expertise with their
    editors. Of course we can all indent blocks; it's just an unnecessary palaver.

    Clearly your point of view is as a language /user/ where languages and
    their characteristics are an invariant that you can't do anything
    about, can't change, and need to work around.

    But some of us devise (and, importanly, implement) languages of our
    own and can be more vocal about misfeatures in others.

    If I'm moving chunks of code around in a C or C++ program, from one
    scope to another, I can get away with leaving the indentation as it is,
    because all the compiler cares about is where the braces are. But I
    *always* adjust the indentation to fit the code's new context.

    Python's use of indentation to indicate scoping just means that I have
    to do what I would have done anyway.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 21:44:56 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 21:37, Keith Thompson wrote:
    Bart <bc@freeuk.com> writes:
    On 28/08/2024 19:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same. >>>>
    Writing editor editor macros in order to work around fundamentally bad >>>> language design is not something a programmer should have to waste
    time on.


    I don't know about Emacs, but in most editors the way you indent a
    block of code is to select the lines, then press "Tab".  Unindenting
    is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done
    by selecting "Tabs to spaces" from the Edit menu, or something
    equally simple and obvious.  Many editor can be set to convert tabs
    to spaces (or vice versa) when saving files, perhaps specific to the
    file type (so you don't muck up your makefiles).
    It takes a special kind of genius to be able to program, and yet
    still have trouble with this kind of thing.

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design. A lesser one
    is having to rely on whatever varied features that 100s of different
    editors may have to do so.

    And yet another, of more significance, if that after you've indented a
    block, it may now merge into an adjacent block that was already at
    that new indent. If you later need to revert that first block back to
    it's original position, you'd better make sure you mark that boundary.

    It is a language design issue pure and simple. Don't try and pin it on
    the users and make out it's due to lack of expertise with their
    editors. Of course we can all indent blocks; it's just an unnecessary
    palaver.

    Clearly your point of view is as a language /user/ where languages and
    their characteristics are an invariant that you can't do anything
    about, can't change, and need to work around.

    But some of us devise (and, importanly, implement) languages of our
    own and can be more vocal about misfeatures in others.

    If I'm moving chunks of code around in a C or C++ program, from one
    scope to another, I can get away with leaving the indentation as it is, because all the compiler cares about is where the braces are. But I
    *always* adjust the indentation to fit the code's new context.

    Python's use of indentation to indicate scoping just means that I have
    to do what I would have done anyway.

    If you glance at the top you will see that my original example involved /temparily/ commenting out the 'if' part of a conditional block. Another example was in temporarily /adding/ an 'if' around a block. And yet
    another (you might want to see my original longer post) was in adding in temporary code but deliberately not using the right indent to make it
    more visible.

    You don't want to waste time getting the layout exactly right and then
    also risk that block disappearing into neighbouring code because
    everything is now at the same indent level.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Andy Walker@anw@cuboid.co.uk to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 23:07:11 2024
    From Newsgroup: comp.lang.misc

    On 27/08/2024 15:18, Bart wrote:
    [Previous discussion and code snipped -- ANW]
    This was an attempt to port an benchmark into Nim; I'd spent the
    best part of an hour trying to get it right, but it kept going
    wrong. In the end I resorted to artificial block terminators.
    The final code looked like that below. Now it is much, much easier
    to see what goes where, and what belongs to what. I can more
    confidently write that extra statement following the opening 'if'.
    With these changes, the porting went much more smooothly.
            if q1!=1:
                for i in countup(2,n):
                    q[i]=p[i]
    #           end
                flips=1
                while true:
                    qq=q[q1]
                    if qq==1:
                        sum+=sign*flips
                        if flips>maxflips:
                            maxflips=flips #                   end
                        break
    #               end
                    q[q1]=q1
                    if q1>=4:
                        i=2
                        j=q1-1
                        while true:
                            t=q[i]
                            q[i]=q[j]
                            q[j]=t
                            i+=1
                            j-=1
                            if i>=j:
                                break #                       end #                   end
    #               end
                    q1=qq
                    flips+=1
    #           end
    #       end
    Sure, people CAN program in such languages, but it is harder work> and more error prone.

    ISTM that the difficulty in reading and writing code like that
    stems not from the indentation, but
    from a
    long narrow
    corridor
    of program
    which is
    difficult to
    read
    and write
    no matter how
    it is indented.
    Variable indentation
    merely
    makes the long
    column wriggly.
    It reminds me of the early autocodes, before the days of block structure.
    I don't know Nim [and only a little of Python], so I can't apportion the difficulty of understanding the code between the language and the chosen programming style. But I can't resist adding a few comments:

    (a) Bart takes 14 lines [from "if q1>=4" to the corresponding "# end"]
    to express the notion [E&OE]

    for i from 2 to q1%2
    swap (q[i], q[q1 - i + 1])

    Small wonder that he found the code hard to get right!

    (b) There are two occurrences of "while true" and two of "break" in the
    code which would not be necessary or appropriate in C or Algol [amongst others]. Again, IMO these contribute to the obscurity of the code.

    (c) I recognise that code as coming from a version of the "Fannkuch" benchmark, so I already have it in C and in Algol 68G. Bart's Nim code
    is substantially longer [around twice the length of the A68G]. Brevity
    is not everything, but if you are forever scrolling from one window to
    the next while your friend gets it all into one window [without losing
    clarity of expression], then guess who is going to find it easier to
    read, write and understand the code.

    (d) Further, if the code is harder to understand, it has more need of explanatory comments, which in turn make the code longer, so harder to
    navigate around.
    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Hertel
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 22:49:04 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 20:27:53 +0100, Bart wrote:

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design.

    If you think the need for refactoring is something that can be solved by “language design”, I’d like to hear how.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 22:49:55 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 12:45:40 +0200, David Brown wrote:

    If you have some code that needs a lot of documentation (and some does),
    then put the comments in a place that does not interfere with reading
    and understanding the code.

    Put them next to the code they’re helping you read and understand.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 23:02:45 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:

    But ok, I found your post and removed all the #end comments. I found it
    just as readable without them as with them.

    You know what? You are right. That example was just too
    well-structured.

    Here’s a more dangerous one:

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"
    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :
    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered"
    )
    #end if
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )
    self._managed_objects = {}
    else :
    raise TypeError("unrecognized argument keyword “%s”" % key)
    #end if
    #end if
    #end for
    return \
    self
    #end register_additional_standard

    versus

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"
    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :
    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered"
    )
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )
    self._managed_objects = {}
    else :
    raise TypeError("unrecognized argument keyword “%s”" % key)
    return self

    I was looking for quite a tricky example I remember seeing on the
    ArjanCodes channel on YouTube, but I can’t find it.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.lang.misc on Thu Aug 29 00:15:39 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 23:07, Andy Walker wrote:
    On 27/08/2024 15:18, Bart wrote:
    [Previous discussion and code snipped -- ANW]
    This was an attempt to port an benchmark into Nim; I'd spent the
    best part of an hour trying to get it right, but it kept going
    wrong. In the end I resorted to artificial block terminators.
    The final code looked like that below. Now it is much, much easier
    to see what goes where, and what belongs to what. I can more
    confidently write that extra statement following the opening 'if'.
    With these changes, the porting went much more smooothly.
             if q1!=1:
                 for i in countup(2,n):
                     q[i]=p[i]
    #           end
                 flips=1
                 while true:
                     qq=q[q1]
                     if qq==1:
                         sum+=sign*flips
                         if flips>maxflips:
                             maxflips=flips
    #                   end
                         break
    #               end
                     q[q1]=q1
                     if q1>=4:
                         i=2
                         j=q1-1
                         while true:
                             t=q[i]
                             q[i]=q[j]
                             q[j]=t
                             i+=1
                             j-=1
                             if i>=j:
                                 break
    #                       end
    #                   end
    #               end
                     q1=qq
                     flips+=1
    #           end
    #       end
    Sure, people CAN program in such languages, but it is harder work> and
    more error prone.

        ISTM that the difficulty in reading and writing code like that
    stems not from the indentation, but
            from a
              long narrow
                corridor
                of program
              which is
                difficult to
                read
                and write
                no matter how
                  it is indented.
            Variable indentation
              merely
              makes the long
              column wriggly.
    It reminds me of the early autocodes, before the days of block structure.
    I don't know Nim [and only a little of Python], so I can't apportion the difficulty of understanding the code between the language and the chosen programming style.  But I can't resist adding a few comments:

      (a) Bart takes 14 lines [from "if q1>=4" to the corresponding "# end"]
    to express the notion [E&OE]

        for i from 2 to q1%2
           swap (q[i], q[q1 - i + 1])

    Small wonder that he found the code hard to get right!

      (b) There are two occurrences of "while true" and two of "break" in the code which would not be necessary or appropriate in C or Algol [amongst others].  Again, IMO these contribute to the obscurity of the code.

      (c) I recognise that code as coming from a version of the "Fannkuch" benchmark, so I already have it in C and in Algol 68G.  Bart's Nim code
    is substantially longer [around twice the length of the A68G].  Brevity
    is not everything, but if you are forever scrolling from one window to
    the next while your friend gets it all into one window [without losing clarity of expression], then guess who is going to find it easier to
    read, write and understand the code.

    This is the only example of my own where #end was used. Doubtless there
    will be real-life code in existence having 7 lines in a block (the body
    of that loop) is justified.


      (d) Further, if the code is harder to understand, it has more need of explanatory comments, which in turn make the code longer, so harder to navigate around.

    The style is one statement per line, especially in Nim and Python where multiple statements per line looks unnatural.

    I have a dozen versions in different languages, most of them derived
    from a version in Lua. There, the loop you mentioned appears like this:

    local i, j = 2, q1 - 1
    repeat q[i], q[j] = q[j], q[i]; i = i + 1; j = j - 1; until i >= j

    Only two lines, so no cause for complaint there! The version in my
    language looks like this:

    i:=2; j:=q1-1
    repeat
    swap(q[i++], q[j--])
    until i>=j

    Since one intent was to compare runtime across languages, I tried to
    keep the algorithm identical.

    This is the Algol68 (A68G) equivalent:

    i:=2; j:=q1-1;
    WHILE
    t:=q[i]; q[i]:=q[j]; q[j]:=t;
    i+:=1;
    j-:=1;
    i<j
    DO SKIP OD

    Here, the bugbear was getting the semicolons right. And letter case.

    (See https://github.com/sal55/langs/blob/master/fannkuch.txt.)

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 00:21:43 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 23:49, Lawrence D'Oliveiro wrote:
    On Wed, 28 Aug 2024 20:27:53 +0100, Bart wrote:

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design.

    If you think the need for refactoring is something that can be solved by “language design”, I’d like to hear how.

    The aim is to not NEED refactoring when you are playing around with
    different, short-term bits of code.

    Requiring letter-case that is exactly right plus indentation that is
    exactly right, plus requiring you to choose between spaces and tabs
    (plus requiring endless 'imports' to added for standard language
    features), is just a nuisance.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 23:44:28 2024
    From Newsgroup: comp.lang.misc

    On 2024-08-28, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    Bart <bc@freeuk.com> writes:
    On 28/08/2024 19:48, David Brown wrote:
    But some of us devise (and, importanly, implement) languages of our
    own and can be more vocal about misfeatures in others.

    If I'm moving chunks of code around in a C or C++ program, from one
    scope to another, I can get away with leaving the indentation as it is, because all the compiler cares about is where the braces are. But I
    *always* adjust the indentation to fit the code's new context.

    Python's use of indentation to indicate scoping just means that I have
    to do what I would have done anyway.

    In a language with brackets or braces, the indentation can adjust itself
    for you.

    The proof of concept for this is the "parinfer" algorithm, for Lisp
    languages. Someone came up with this a bunch of years ago and now
    it's fairly widely implemented.

    Parinfer creates a real-time link between indentation and parentheses.

    It can be configured to infer one from the other: you can manually
    control indentation and have parentheses magically appear and disappear
    as needed, or you can control parentheses and have the code indent
    itself.

    Likely, a much more complicated version of the algorithm could work
    for "C likes" and others. Maybe someone has done it by now? No idea.

    There are some animated demos on the original home page, and maybe
    elsewhere:

    https://shaunlebron.github.io/parinfer/

    I use a somewhat poor but usable Vim implementation of this.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 17:23:25 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:
    But ok, I found your post and removed all the #end comments. I found it
    just as readable without them as with them.

    You know what? You are right. That example was just too
    well-structured.

    Here’s a more dangerous one:

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"

    That's not the conventional way to format a docstring. If you're using backslashes to splice lines in Python, it's likely you're doing
    something wrong.

    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :

    I think "is not None" is more idiomatic.

    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered"
    )

    You don't need the \ if you put the ( on the same line.

    #end if
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )

    Again, you've decided how you want to place parentheses and you're
    forcing the syntax to cater to that. I might write that as:

    self.register(
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )

    self._managed_objects = {}
    else :

    You leave a space between "else" and ":". It's not wrong, but it's not something I've ever seen. It's likely to be just a little jarring to
    readers.

    raise TypeError("unrecognized argument keyword “%s”" % key)

    Do you have a requirement to use older versions of Python that don't
    support f-strings?

    #end if
    #end if
    #end for
    return \
    self

    Why not just "return self"?

    #end register_additional_standard

    versus

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"
    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :
    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered"
    )
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )
    self._managed_objects = {}
    else :
    raise TypeError("unrecognized argument keyword “%s”" % key)
    return self

    Again, the #end comments don't make it any more readable *for me*.
    I suspect that would be even more true for more experienced Python
    programmers.

    I was looking for quite a tricky example I remember seeing on the
    ArjanCodes channel on YouTube, but I can’t find it.

    In any language, if a block of code is so deeply indented that it's
    confusing, you should consider refactoring it. (Though that's not
    always the answer.)

    I once reviewed some C code with misleading indentation. Depending on
    the viewer's tab settings (4 vs 8 columns) it looked either like this:

    if (condition)
    this;
    that;

    or like this:

    if (condition)
    this;
    that;

    Of course it meant the same to the compiler.

    In any language, I think it's important to use consistent indentation
    that reflects the structure of the code, and to avoid mixing tabs and
    spaces. (My personal preference is to use spaces exclusively, but I'll
    conform to what existing code does.) As I've said elsethread, Python's
    rules just force me to do what I would have done anyway.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.programmer,comp.lang.misc,comp.editors on Thu Aug 29 02:29:55 2024
    From Newsgroup: comp.lang.misc

    [ NG list changed: removed shell, added editors; Fup-to set: editors ]

    On 28.08.2024 20:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste
    time on.

    I don't know about Emacs, but in most editors the way you indent a block
    of code is to select the lines, then press "Tab". Unindenting is "shift-Tab". [...]

    I also don't know about Emacs. But there's the question how "selected
    region" [LD'O] or "select the lines" [DB] is achieved. If there's only primitive editing commands available (i.e. selection by mouse, or long
    clumsy keyboard sequences) it may be irrelevant whether you indent code
    in a Python or in a "C" program. If you're using editors like Vi that
    block selection can be done with '%' and the indent with '>%' and the
    reverse indent with '<%' (without the quotes); but that works only if
    you have the syntactical elements (the braces, parenthesis, brackets)
    as definition of the program block. That won't work for a block in a
    language like Python where blocks are defined by layout (by the grade
    of indentation); then you'd have to resort to the primitive editors'
    selection features, mouse/menus or more laborious keyboard commands.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 01:16:24 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 00:21:43 +0100, Bart wrote:

    On 28/08/2024 23:49, Lawrence D'Oliveiro wrote:

    On Wed, 28 Aug 2024 20:27:53 +0100, Bart wrote:

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design.

    If you think the need for refactoring is something that can be solved
    by “language design”, I’d like to hear how.

    The aim is to not NEED refactoring when you are playing around with different, short-term bits of code.

    “Playing around” is exactly one of those situations where you will need to do all kinds of things to the code, including refactoring.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 01:19:45 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 17:23:25 -0700, Keith Thompson wrote:

    That's not the conventional way to format a docstring. If you're using backslashes to splice lines in Python, it's likely you're doing
    something wrong.

    What exactly is wrong?

    I think "is not None" is more idiomatic.

    When I want an equality comparison, I use “==”, not “is”.

    You don't need the \ if you put the ( on the same line.

    But I do otherwise.

    You leave a space between "else" and ":". It's not wrong, but it's not something I've ever seen.

    People who look at my code tend to get triggered by the little things;
    maybe it’s a way to avoid thinking about the big things?

    In any language, if a block of code is so deeply indented that it's confusing, you should consider refactoring it. (Though that's not
    always the answer.)

    The point being, the same kind of code in a language with explicit
    statement brackets would reach the point of confusion later, rather than sooner.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.programmer,comp.lang.misc,comp.editors on Thu Aug 29 01:22:18 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 02:29:55 +0200, Janis Papanagnou wrote:

    If there's only
    primitive editing commands available (i.e. selection by mouse, or long
    clumsy keyboard sequences) it may be irrelevant whether you indent code
    in a Python or in a "C" program. If you're using editors like Vi that
    block selection can be done with '%' and the indent with '>%' and the
    reverse indent with '<%' (without the quotes); but that works only if
    you have the syntactical elements (the braces, parenthesis, brackets) as definition of the program block. That won't work for a block in a
    language like Python where blocks are defined by layout (by the grade of indentation); then you'd have to resort to the primitive editors'
    selection features, mouse/menus or more laborious keyboard commands.

    I have Emacs commands defined to jump quickly between lines with matching indentation. That lets me easily select entire statement blocks in Python.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Aug 28 19:19:38 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 17:23:25 -0700, Keith Thompson wrote:

    That's not the conventional way to format a docstring. If you're using
    backslashes to splice lines in Python, it's likely you're doing
    something wrong.

    What exactly is wrong?

    Perhaps "wrong" overstates it, but your code certainly doesn't follow
    common Python conventions.

    https://peps.python.org/pep-0257/

    I think "is not None" is more idiomatic.

    When I want an equality comparison, I use “==”, not “is”.

    You don't need the \ if you put the ( on the same line.

    But I do otherwise.

    So I see. I don't know why -- and I'm ok with that.

    You leave a space between "else" and ":". It's not wrong, but it's not
    something I've ever seen.

    People who look at my code tend to get triggered by the little things;
    maybe it’s a way to avoid thinking about the big things?

    Why would I want to avoid thinking about the big things?

    One of Henry Spencer's Ten Commandments for C Programmers seems relevant (indirectly, of course):

    Thou shalt make thy program's purpose and structure clear to thy
    fellow man by using the One True Brace Style, even if thou likest it
    not, for thy creativity is better used in solving problems than in
    creating beautiful new impediments to understanding.

    https://www.lysator.liu.se/c/ten-commandments.html

    My impression is that your unconventional style indicates a relative
    lack of experience in Python. Maybe that's an invalid conclusion, but
    it's one that others are likely to reach as well.

    And if you want to discuss Python, I suggest that comp.lang.python would
    be a better place to do so. I see that you already post there. (And
    you seem to have a problem with the gateway to the python-list mailing
    list, for reasons you have declined to explain.) I follow that
    newsgroup, and I'm going to bow out of this thread here.

    In any language, if a block of code is so deeply indented that it's
    confusing, you should consider refactoring it. (Though that's not
    always the answer.)

    The point being, the same kind of code in a language with explicit
    statement brackets would reach the point of confusion later, rather than sooner.

    I'm not convinced of that.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.programmer,comp.lang.misc,comp.editors on Thu Aug 29 04:30:16 2024
    From Newsgroup: comp.lang.misc

    On 29.08.2024 03:22, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 02:29:55 +0200, Janis Papanagnou wrote:

    If there's only
    primitive editing commands available (i.e. selection by mouse, or long
    clumsy keyboard sequences) it may be irrelevant whether you indent code
    in a Python or in a "C" program. If you're using editors like Vi that
    block selection can be done with '%' and the indent with '>%' and the
    reverse indent with '<%' (without the quotes); but that works only if
    you have the syntactical elements (the braces, parenthesis, brackets) as
    definition of the program block. That won't work for a block in a
    language like Python where blocks are defined by layout (by the grade of
    indentation); then you'd have to resort to the primitive editors'
    selection features, mouse/menus or more laborious keyboard commands.

    I have Emacs commands defined to jump quickly between lines with matching indentation. That lets me easily select entire statement blocks in Python.

    I'm sure you have. - But wasn't that the point someone made upthread:
    "Writing editor editor macros in order to work around fundamentally bad language design is not something a programmer should have to waste time
    on." [Muttley@...] - I'm just feeling lucky with brackets and Vi. YMMV.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.programmer,comp.lang.misc,comp.editors on Thu Aug 29 05:50:29 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 04:30:16 +0200, Janis Papanagnou wrote:

    On 29.08.2024 03:22, Lawrence D'Oliveiro wrote:

    I have Emacs commands defined to jump quickly between lines with
    matching indentation. That lets me easily select entire statement
    blocks in Python.

    I'm sure you have. - But wasn't that the point someone made upthread:

    Not really, no.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 07:28:58 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 20:48:08 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste time on. >>


    I don't know about Emacs, but in most editors the way you indent a block
    of code is to select the lines, then press "Tab". Unindenting is >"shift-Tab". Changing tabs to spaces or spaces to tabs is done by
    selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious. Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type (so
    you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet still
    have trouble with this kind of thing.

    Don't be a patronising prick, it doesn't help your argument. Personally I
    have better things to do that figure out some obscure functionality of vim
    to achieve something I shouldn't have to do in the first place if the
    language was designed properly. Thankfully I don't have to use Python much.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 11:49:35 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 02:16, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 00:21:43 +0100, Bart wrote:

    On 28/08/2024 23:49, Lawrence D'Oliveiro wrote:

    On Wed, 28 Aug 2024 20:27:53 +0100, Bart wrote:

    The main problem isn't in changing the indentation of a block of code; >>>> it is in HAVING to do so because of poor language design.

    If you think the need for refactoring is something that can be solved
    by “language design”, I’d like to hear how.

    The aim is to not NEED refactoring when you are playing around with
    different, short-term bits of code.

    “Playing around” is exactly one of those situations where you will need to
    do all kinds of things to the code, including refactoring.


    Here:

    if a == b:
    s1
    return
    s2
    s3

    that return statement is added temporarily for some reason that is not relevant to the discussion.

    Real life code would have much busier statements, and the whole thing
    would in the middle of lots of other stuff that can include actual
    return statements.

    The problem is that that line doesn't stand out, when later you have to
    find it to remove it or comment it. It blends into the surrounding code.

    Without the constraints imposed by the language, I could just write it as:

    if a == b:
    s1
    RETURN
    s2
    s3

    NOW it stands out! Of course, I could just do:

    if a == b:
    s1
    return # TEMPORARY RETURN
    s2
    s3

    But this is extra effort that shouldn't be necessary, like adding #end comments. I might for example move that line to a different part of the function, but it might use a different indent level.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Dmitry A. Kazakov@mailbox@dmitry-kazakov.de to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 13:31:01 2024
    From Newsgroup: comp.lang.misc

    On 2024-08-29 12:49, Bart wrote:

    Without the constraints imposed by the language, I could just write it as:

        if a == b:
            s1
    RETURN
            s2
            s3

    NOW it stands out!

    In Ada I use indentation for the purpose:

    if A = B then -- This I will remove later
    s1;
    end if;
    s2;
    s3;

    I remember FORTRAN in its glory days had D-comments. In the first column
    the letter D meant a conditional, compiled in the debug mode, ignored otherwise.
    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 14:01:05 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 02:23, Keith Thompson wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:
    But ok, I found your post and removed all the #end comments. I found it >>> just as readable without them as with them.

    You know what? You are right. That example was just too
    well-structured.

    So why not try to write /all/ your code in a well-structured manner, so
    that you don't feel the need to add these "#end" comments?


    Here’s a more dangerous one:

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"

    That's not the conventional way to format a docstring. If you're using backslashes to splice lines in Python, it's likely you're doing
    something wrong.

    Agreed 100%.


    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :

    I think "is not None" is more idiomatic.

    I don't know if that is true or not that it is more idiomatic - I would certainly be happy with either.

    def register_additional_standard(self, managed_objects) :
    """
    registers additional standard interfaces that are not automatically
    installed at Connection creation time. Currently the only one is
    the object-manager interface, registered with

    «conn».register_additional_standard(managed_objects = True)
    """

    if managed_objects :
    if self._managed_objects != None :
    raise asyncio.InvalidStateError("object manager
    interface already registered")
    self.register(
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )
    self._managed_objects = {}
    return self

    (Usenet formatting is limited to 72 characters standard - modern
    programming is not. Overly long lines are not good, but a hard limit
    at, say, 80 characters is a bad idea.)



    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered" >> )

    You don't need the \ if you put the ( on the same line.

    Line continuation characters in Python are usually an indicator of poor formatting, or an unhealthy obsession with line length limits.


    #end if
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )

    Again, you've decided how you want to place parentheses and you're
    forcing the syntax to cater to that. I might write that as:

    self.register(
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )

    self._managed_objects = {}
    else :

    You leave a space between "else" and ":". It's not wrong, but it's not something I've ever seen. It's likely to be just a little jarring to readers.

    I personally prefer a space before the colon in Python. It is probably
    less common than no space, but it is certainly not a rare habit.


    raise TypeError("unrecognized argument keyword “%s”" % key)

    Do you have a requirement to use older versions of Python that don't
    support f-strings?

    #end if
    #end if
    #end for
    return \
    self

    Why not just "return self"?

    Indeed.


    #end register_additional_standard

    versus

    def register_additional_standard(self, **kwargs) :
    "registers additional standard interfaces that are not automatically" \
    " installed at Connection creation time. Currently the only one is" \
    " the object-manager interface, registered with\n" \
    "\n" \
    " «conn».register_additional_standard(managed_objects = True)\n"
    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    if self._managed_objects != None :
    raise asyncio.InvalidStateError \
    (
    "object manager interface already registered" >> )
    self.register \
    (
    path = "/",
    interface = ManagedObjectsHandler(),
    fallback = True
    )
    self._managed_objects = {}
    else :
    raise TypeError("unrecognized argument keyword “%s”" % key)
    return self

    Again, the #end comments don't make it any more readable *for me*.
    I suspect that would be even more true for more experienced Python programmers.

    I don't know if I am more experienced than you in Python (I may have
    been using Python for longer, but you may have worked with it more), but
    I would say that the "#end" comments directly detract from readability.


    I was looking for quite a tricky example I remember seeing on the
    ArjanCodes channel on YouTube, but I can’t find it.

    In any language, if a block of code is so deeply indented that it's confusing, you should consider refactoring it. (Though that's not
    always the answer.)

    Agreed.


    I once reviewed some C code with misleading indentation. Depending on
    the viewer's tab settings (4 vs 8 columns) it looked either like this:

    if (condition)
    this;
    that;

    or like this:

    if (condition)
    this;
    that;

    Of course it meant the same to the compiler.

    As someone who works with C programming that is often high-reliability
    (not necessarily safety critical, but updates after production can be
    very expensive), both are unacceptable in the kind of coding standards
    we use. I accept single-line "if" statements without braces if they are simple enough, otherwise braces are required.

    if (condition) return;

    if (condition) {
    return;
    } else {
    break;
    }

    If the "true" statement is on a separate line, braces are /always/
    required for my type of code. Almost any indentation is done inside a
    pair of braces - it keeps everything simple and consistent, and it's
    easy to spot mistakes.


    In any language, I think it's important to use consistent indentation
    that reflects the structure of the code, and to avoid mixing tabs and
    spaces. (My personal preference is to use spaces exclusively, but I'll conform to what existing code does.) As I've said elsethread, Python's
    rules just force me to do what I would have done anyway.


    I do the same. (Well, I use tabs more than spaces, but otherwise I do
    the same.)


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 14:05:41 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 03:19, Lawrence D'Oliveiro wrote:
    On Wed, 28 Aug 2024 17:23:25 -0700, Keith Thompson wrote:

    That's not the conventional way to format a docstring. If you're using
    backslashes to splice lines in Python, it's likely you're doing
    something wrong.

    What exactly is wrong?

    I think "is not None" is more idiomatic.

    When I want an equality comparison, I use “==”, not “is”.

    You don't need the \ if you put the ( on the same line.

    But I do otherwise.

    You leave a space between "else" and ":". It's not wrong, but it's not
    something I've ever seen.

    People who look at my code tend to get triggered by the little things;
    maybe it’s a way to avoid thinking about the big things?

    """
    There are two ways of constructing a software design: One way is to make
    it so simple that there are obviously no deficiencies, and the other way
    is to make it so complicated that there are no obvious deficiencies. The
    first method is far more difficult.
    """

    You are clearly aiming for the second method here - put in so much extra
    crap and silliness that readers get caught up in that instead of
    noticing that most of the function is meaningless.



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 14:24:01 2024
    From Newsgroup: comp.lang.misc

    On 28/08/2024 21:27, Bart wrote:
    On 28/08/2024 19:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same.

    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste
    time on.



    I don't know about Emacs, but in most editors the way you indent a
    block of code is to select the lines, then press "Tab".  Unindenting
    is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done by
    selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious.  Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type
    (so you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet still
    have trouble with this kind of thing.

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design.

    If I am adding or removing blocks (such as surrounding existing code in
    a new conditional), then I /have/ to change the indentation - in /any/ language. (I use indents in my assembly programming too.) Call it OCD
    or compulsive behaviour if you like, but I cannot consider code to be
    finished - even to the level of a quick compile or test - if the
    indentation is not correct.

    I simply cannot see the problem with Python here, because I would not
    indent things in any other way in any language.

    The only thing I see as annoying in Python is when you have two or three indentations left hanging :

    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()

    That looks unfinished to me. So I will add a "return" at the end (with
    a single tab indent, in this case). If it is not the end of the
    function, I will sometimes use a "pass" to pull back the indent level.


    A lesser one
    is having to rely on whatever varied features that 100s of different
    editors may have to do so.

    I also rely on editors being able to accept keypresses, to load and save files, and to have features like "search".

    Of course, being a sane software developer, I do most of my programming
    using editors that are suitable for software development. Most
    professional carpenters use hammers for their nails, rather than bashing
    them in with stones - it's the same thing, really.


    And yet another, of more significance, if that after you've indented a block, it may now merge into an adjacent block that was already at that
    new indent. If you later need to revert that first block back to it's original position, you'd better make sure you mark that boundary.


    So mark the boundary. Add a blank line. Put a comment line describing
    the steps of the function. You are making up problems for which you
    already have good solutions that you would be using in any programming language.

    It is a language design issue pure and simple. Don't try and pin it on
    the users and make out it's due to lack of expertise with their editors.
    Of course we can all indent blocks; it's just an unnecessary palaver.

    Clearly your point of view is as a language /user/ where languages and
    their characteristics are an invariant that you can't do anything about, can't change, and need to work around.

    But some of us devise (and, importanly, implement) languages of our own
    and can be more vocal about misfeatures in others.


    Having made your own language(s) gives you no more and no less right to comment about features of other languages that you like or dislike.

    Your problem here is that you are obsessed with finding things that you
    want to see as misfeatures, design flaws, or problems in other languages
    - and then obsess about how you can find new ways to make it more
    difficult to "work around" them.

    Don't you ever just accept that a language is the way it is, and it is perfectly useable that way? Or think that perhaps other people in the
    world know better than you do about how they want their language to
    work? Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and decided
    that making it the way they did was the best choice overall for the
    language they wanted?

    As Bjarne Stustroup said, there are two kinds of programming languages -
    those that people complain about, and those that no one uses.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 14:30:27 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    On Wed, 28 Aug 2024 20:48:08 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    Writing editor editor macros in order to work around fundamentally bad
    language design is not something a programmer should have to waste
    time on.



    I don't know about Emacs, but in most editors the way you indent a
    block of code is to select the lines, then press "Tab".  Unindenting
    is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done by
    selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious.  Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type
    (so you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet still
    have trouble with this kind of thing.

    Don't be a patronising prick, it doesn't help your argument. Personally I have better things to do that figure out some obscure functionality of vim
    to achieve something I shouldn't have to do in the first place if the language was designed properly. Thankfully I don't have to use Python much.


    Then don't use vim - use an editor that suits your needs.

    If you are trying to claim that you do software development, and that
    the editor(s) you use regularly do not have easily available functions
    for indenting and un-indenting sections of code, then you are either
    lying, or you /are/ an aforementioned special kind of genius.

    Presumably you are /not/ trying to claim that - you are just trolling.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ben Bacarisse@ben@bsb.me.uk to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 13:50:01 2024
    From Newsgroup: comp.lang.misc

    "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

    On 2024-08-29 12:49, Bart wrote:

    Without the constraints imposed by the language, I could just write it as: >> if a == b:
    s1
    RETURN
    s2
    s3
    NOW it stands out!

    In Ada I use indentation for the purpose:

    if A = B then -- This I will remove later
    s1;
    end if;
    s2;
    s3;

    I remember FORTRAN in its glory days had D-comments. In the first column
    the letter D meant a conditional, compiled in the debug mode, ignored otherwise.

    That was a non-standard extension, so it was not really part of FORTRAN
    but just some FORTRAN implementations. (The ones I have used didn't
    have that, for example.)
    --
    Ben.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From John Ames@commodorejohn@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 08:52:46 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 14:24:01 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    Don't you ever just accept that a language is the way it is, and it
    is perfectly useable that way? Or think that perhaps other people in
    the world know better than you do about how they want their language
    to work? Has it never occurred to you that the people behind a given language - such as Python - considered various alternatives and
    decided that making it the way they did was the best choice overall
    for the language they wanted?

    They probably did - but did they do that *because* of the point in
    question, in spite of it, or without any meaningful inclination toward
    or against it? There are plenty of other aspects about Python that may
    tip the balance in spite of its annoyances.

    F'rinstance, the *very* comprehensive set of libraries make bashing out
    quick utilities to do A Complex Thing often very simple. (That was the
    reason I first used it - needed a quick-'n-easy way to programmatically
    deliver data in a POST request from a Windows box in production, and it
    beat the hell out of trying to wrap my head around Win32 network
    programming.) But if the language "wins" on that score, that doesn't
    mean its annoyances or flaws are any less real or worthy of complaint.

    Like, obviously it's way too late in the game for Python to change this
    now. But we can still say it's stupid for them to have done it that way
    in the first place. Is that a matter of opinion? Sure, but that's never
    stopped anybody from expressing themselves re: any other language. (How
    many people are still bitching about C being "insecure," 50+ years down
    the line?)

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 16:19:45 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 14:30:27 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    Presumably you are /not/ trying to claim that - you are just trolling.

    Ah ok, you're the type who thinks anyone who disagrees with you is a troll. You're not worth the effort mate.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 18:44:35 2024
    From Newsgroup: comp.lang.misc

    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.

    LOL. (You appear to be joking. - If not, continue reading...)

    But what makes you think that his needs are not covered by Vim?


    If you are trying to claim that you do software development, and that
    the editor(s) you use regularly do not have easily available functions
    for indenting and un-indenting sections of code, then you are either
    lying, or you /are/ an aforementioned special kind of genius.

    Vim is an editor that has the most simple and also very powerful
    indenting for well structured data and programs I've yet seen.
    (Not mentioning its equally powerful other editing facilities.)

    And even badly designed languages can be indented in the same
    ways that other editors (more primitive ones or Emacs) provide.
    Not as efficient as with previously mentioned cleanly designed
    data or languages, but as efficient as all these other editors.

    Why should he use any editor that is - in the general case, for
    editing all sorts of data - mostly much less efficient than Vim?
    (From the handful of popular editors I don't see any candidate.)

    But this is not an untypical reflex on the Internet; ignoring
    factual design issues, questioning the used tools instead, and
    giving folks with different experiences and preferences names.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 21:27:36 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 17:52, John Ames wrote:
    On Thu, 29 Aug 2024 14:24:01 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    Don't you ever just accept that a language is the way it is, and it
    is perfectly useable that way? Or think that perhaps other people in
    the world know better than you do about how they want their language
    to work? Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and
    decided that making it the way they did was the best choice overall
    for the language they wanted?

    They probably did - but did they do that *because* of the point in
    question, in spite of it, or without any meaningful inclination toward
    or against it? There are plenty of other aspects about Python that may
    tip the balance in spite of its annoyances.


    I don't know the early history of Python, so I can't answer that. But
    there can be no doubt that the BDFL and other "founding fathers" of the language were aware of the pros and cons of making white space
    significant for block structuring in the language, and that they
    actively decided to make its syntax the way it is as the best balance,
    in their opinions, for the expected use of the language. However, it is
    also likely that they did not predict where the language would be, and
    how it would be used, decades later. Maybe if they had had a crystal
    ball they would have designed things differently - maybe not.

    /All/ languages, except perhaps Bart's private language that is only
    used by him, have their annoyances. I have worked at least a little
    with a fair number of languages, and I've never seen one that I thought
    was "perfect". But different people have different things that the like
    and dislike about any given language.

    So if you have the choice of which language to use (many programmers do
    not), you pick one that has more things you like for the task in
    question in comparison to the things you don't like.

    F'rinstance, the *very* comprehensive set of libraries make bashing out
    quick utilities to do A Complex Thing often very simple. (That was the
    reason I first used it - needed a quick-'n-easy way to programmatically deliver data in a POST request from a Windows box in production, and it
    beat the hell out of trying to wrap my head around Win32 network programming.) But if the language "wins" on that score, that doesn't
    mean its annoyances or flaws are any less real or worthy of complaint.

    Like, obviously it's way too late in the game for Python to change this
    now. But we can still say it's stupid for them to have done it that way
    in the first place. Is that a matter of opinion? Sure, but that's never stopped anybody from expressing themselves re: any other language. (How
    many people are still bitching about C being "insecure," 50+ years down
    the line?)


    You are welcome to your opinions on languages - I have plenty of my own
    (and I prefer explicit block delimiters - I would even go further in
    languages like C and insist on them in more situations). But it's
    important to understand that these are opinions - the designers of
    Python were /not/ stupid to have made the language that way. They just
    had different opinions from you, and the had a much better basis for
    forming those opinions than you or I.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 21:29:15 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 18:19, Muttley@dastardlyhq.com wrote:
    On Thu, 29 Aug 2024 14:30:27 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    Presumably you are /not/ trying to claim that - you are just trolling.

    Ah ok, you're the type who thinks anyone who disagrees with you is a troll.

    No, I was talking about /you/. I don't know of anyone here with whom I
    don't disagree at times, and most of the rest are not trolling.

    You're not worth the effort mate.


    Feel free to ignore my posts.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 21:36:08 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 18:44, Janis Papanagnou wrote:
    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.

    LOL. (You appear to be joking. - If not, continue reading...)


    I was not joking.

    But what makes you think that his needs are not covered by Vim?

    You seem to have missed the point - sorry if I was not clear.

    He complained that he didn't want to learn complicated macros in Vim
    just to be able to indent or un-indent lines of code. The solution is
    obvious - he should use an editor other than Vim.

    He could, of course, learn how to use Vim. It's a perfectly good editor
    with a lot of features. It's never been my cup of tea, and nor has
    Emacs - but that's preference and habit, and says nothing about whether
    or not it is a good editor or useful for other people.

    There are more than enough decent editors to choose from, that cover the
    basic needs of programmers. Some people use one editor for everything,
    others use a range for different purposes - whatever suits you. But it
    is pretty absurd to complain that it is difficult to indent code just
    because you (i.e., Muttley) think it is hard to do in one particular editor.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 22:57:17 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 14:24:01 +0200, David Brown wrote:

    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()

    That looks unfinished to me. So I will add a "return" at the end (with
    a single tab indent, in this case).

    A redundant “return” ... kind of like my redundant “#end” comments, except
    yours work in a more restricted set of places ...

    Don't you ever just accept that a language is the way it is, and it is perfectly useable that way?

    Of course not.

    Or think that perhaps other people in the world know better than you do
    about how they want their language to work?

    And vice versa.

    Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and decided
    that making it the way they did was the best choice overall for the
    language they wanted?

    Barring a few obvious stupidities, yes of course they were, and are, smart people.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 23:03:54 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 14:01:05 +0200, David Brown wrote:

    On 29/08/2024 02:23, Keith Thompson wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:

    But ok, I found your post and removed all the #end comments. I found
    it just as readable without them as with them.

    You know what? You are right. That example was just too
    well-structured.

    So why not try to write /all/ your code in a well-structured manner, so
    that you don't feel the need to add these "#end" comments?

    Because not all examples can be made that neat, as I demonstrated.

    def register_additional_standard(self, managed_objects) :
    """
    registers additional standard interfaces that are not
    automatically installed at Connection creation time. Currently
    the only one is the object-manager interface, registered with

    «conn».register_additional_standard(managed_objects = True)
    """

    Note that Python’s indentation rules don’t apply to multiline string literals -- don’t you wish they did? So you end up with all that extra
    space within the literal. Do you see why I prefer to avoid that?

    Line continuation characters in Python are usually an indicator of poor formatting, or an unhealthy obsession with line length limits.

    I like to keep within a line length limit of about 100 characters.

    I don't know if I am more experienced than you in Python (I may have
    been using Python for longer, but you may have worked with it more), but
    I would say that the "#end" comments directly detract from readability.

    Think about why you bother to indent code in languages where the compiler ignores such indentation anyway: it means you are expressing the structure
    of code in two different ways, one via statement brackets, and the other
    via indentation. This redundancy aids in understanding that the code does
    what you think it does.

    Python gets rid of this redundancy, by having the compiler take notice of
    the whitespace and removing the statement bracketing symbols. So I put it back, by adding statement bracketing symbols that the compiler ignores.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.lang.misc on Fri Aug 30 00:49:25 2024
    From Newsgroup: comp.lang.misc

    On 29/08/2024 13:24, David Brown wrote:
    On 28/08/2024 21:27, Bart wrote:
    On 28/08/2024 19:48, David Brown wrote:
    On 28/08/2024 19:43, Muttley@dastardlyhq.com wrote:
    On Tue, 27 Aug 2024 21:34:54 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 27 Aug 2024 11:26:18 +0100, Bart wrote:

    (2) You want to temporarily comment out an 'if' line so that the
    following block is unconditional. You can't do that with also
    unindenting the block.

    In Emacs, I have commands defined to adjust the indentation of the
    selected region. Surely any other decent editor would offer the same. >>>>
    Writing editor editor macros in order to work around fundamentally bad >>>> language design is not something a programmer should have to waste
    time on.



    I don't know about Emacs, but in most editors the way you indent a
    block of code is to select the lines, then press "Tab".  Unindenting
    is "shift-Tab".  Changing tabs to spaces or spaces to tabs is done by
    selecting "Tabs to spaces" from the Edit menu, or something equally
    simple and obvious.  Many editor can be set to convert tabs to spaces
    (or vice versa) when saving files, perhaps specific to the file type
    (so you don't muck up your makefiles).

    It takes a special kind of genius to be able to program, and yet
    still have trouble with this kind of thing.

    The main problem isn't in changing the indentation of a block of code;
    it is in HAVING to do so because of poor language design.

    If I am adding or removing blocks (such as surrounding existing code in
    a new conditional), then I /have/ to change the indentation - in /any/ language.  (I use indents in my assembly programming too.)  Call it OCD
    or compulsive behaviour if you like, but I cannot consider code to be finished - even to the level of a quick compile or test - if the
    indentation is not correct.

    I simply cannot see the problem with Python here, because I would not
    indent things in any other way in any language.

    The only thing I see as annoying in Python is when you have two or three indentations left hanging :

    def foo(a, b, c) :
        if a :
            if b :
                if c :
                    doThis()

    Let's assume you know this ends here (as there is no concrete bit of
    syntax that will confirm it).

    You need to add another statement to that 'if b' block. Even with just
    two intervening lines, you need to take some care. With more, you either
    have to work your way down from 'if b' then move right one tab, or start
    from the first statement ('if c') and work down from that. At the same
    keep an eye out for cues as to the end of the 'if b' block.

    It should look like this afterwards:

    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()
    bnewstmt

    That new statement looks rather lonely and exposed though! Do the same
    with 'if a', and it becomes:


    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()
    bnewstmt

    # comment
    # comment
    anewstmt


    That looks unfinished to me.

    It's just too 'open'. The contents of foo look like they're leaking into
    the rest of the program. As it is, someone looking at this in the future wanting to a a new statement to 'if a:' might think it ends before the comments since that 'anewstmt' is too far from the main body.

    It needs delimiters:


    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()
    end
    bnewstmt
    end

    # comment
    # comment
    anewstmt
    end
    end

    Now you know that 'if a' doesn't end at that blank line, because no
    'end' has been seen for it.

    So I will add a "return" at the end (with
    a single tab indent, in this case).  If it is not the end of the
    function, I will sometimes use a "pass" to pull back the indent level.

    So you have problems too. Would you have needed 'return' if 'end's had
    been used in the original?

    Of course, being a sane software developer, I do most of my programming using editors that are suitable for software development.  Most professional carpenters use hammers for their nails, rather than bashing them in with stones - it's the same thing, really.


    And yet another, of more significance, if that after you've indented a
    block, it may now merge into an adjacent block that was already at
    that new indent. If you later need to revert that first block back to
    it's original position, you'd better make sure you mark that boundary.


    So mark the boundary.  Add a blank line.  Put a comment line describing the steps of the function.  You are making up problems for which you already have good solutions that you would be using in any programming language.

    How about just fixing the ******* language? That must be better than a
    million programmers wasting time creating their own fixes.

    Having made your own language(s) gives you no more and no less right to comment about features of other languages that you like or dislike.


    I had my opinions even before I used my own stuff.

    One thing I despised was the begin-end business in Algol60 and Pascal,
    which has the same nuisance as braces in C-like languages.

    I didn't like writing 'end else begin' any more than '} else {'. My
    stuff (and a few languages have picked up on it), uses just 'else',
    which also limits the placement possibilities when you have one token
    rather than three.


    Your problem here is that you are obsessed with finding things that you
    want to see as misfeatures, design flaws, or problems in other languages

    Yes. I'm into language design. But I'm also interested in aspects of it
    that many disregard, such as microfeatures, or ease of deployment.

    - and then obsess about how you can find new ways to make it more
    difficult to "work around" them.

    Fortunately I don't need to work with them much. If I did, I would find
    the means to make them tolerable.


    Don't you ever just accept that a language is the way it is, and it is perfectly useable that way?

    Well, I used Fortran IV for a year. But presumably lots of people
    weren't that happy with it as we've since had Fortran 77, 90, 95, 2008,
    2018 and 2023.

    It's not just me!


      Or think that perhaps other people in the
    world know better than you do about how they want their language to
    work?  Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and decided
    that making it the way they did was the best choice overall for the
    language they wanted?

    Python is full of ill-advised choices. And it's become almost as much of
    a monster as C++, with a million incompatible features bolted on.

    I'm not surprised that mere matters of syntax have low priority.


    As Bjarne Stustroup said, there are two kinds of programming languages - those that people complain about, and those that no one uses.


    Funny, I can complain about lots of languages that I never use!
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Aug 29 16:57:21 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    [...]
    Think about why you bother to indent code in languages where the compiler ignores such indentation anyway: it means you are expressing the structure of code in two different ways, one via statement brackets, and the other
    via indentation. This redundancy aids in understanding that the code does what you think it does.

    Python gets rid of this redundancy, by having the compiler take notice of the whitespace and removing the statement bracketing symbols. So I put it back, by adding statement bracketing symbols that the compiler ignores.

    You might find Bython useful.

    https://github.com/mathialo/bython

    (I don't, but you might.)
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 02:53:37 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 18:44:35 +0200, Janis Papanagnou wrote:

    Vim is an editor that has the most simple and also very powerful
    indenting for well structured data and programs I've yet seen. (Not mentioning its equally powerful other editing facilities.)

    Vim is only good for text-editing, though. It assumes a file is split into lines. Emacs makes no such assumption, and can also edit non-text files.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 02:55:06 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 16:57:21 -0700, Keith Thompson wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    [...]
    Think about why you bother to indent code in languages where the
    compiler ignores such indentation anyway: it means you are expressing
    the structure of code in two different ways, one via statement
    brackets, and the other via indentation. This redundancy aids in
    understanding that the code does what you think it does.

    Python gets rid of this redundancy, by having the compiler take notice
    of the whitespace and removing the statement bracketing symbols. So I
    put it back, by adding statement bracketing symbols that the compiler
    ignores.

    Another reason for “#end” comments is they give me something to jump to in the editor.

    I have Emacs commands defined to move quickly between lines with matching indentation. Since I have these at the beginning and end of every compound construct, that allows me easy navigation around my code.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 10:01:13 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 01:03, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 14:01:05 +0200, David Brown wrote:

    On 29/08/2024 02:23, Keith Thompson wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:

    But ok, I found your post and removed all the #end comments. I found >>>>> it just as readable without them as with them.

    You know what? You are right. That example was just too
    well-structured.

    So why not try to write /all/ your code in a well-structured manner, so
    that you don't feel the need to add these "#end" comments?

    Because not all examples can be made that neat, as I demonstrated.

    Your example could easily have been written in a more structured manner
    than you did. Keith and I both demonstrated that. (And when you remove
    the useless stuff from your function, it's even simpler.)

    I agree that not /all/ code can easily be written in a neat,
    well-structured manner - and that occasionally breaking your normal
    coding convention rules can bring out patterns in the code that make it
    easier to understand, and easier to write correctly. But the solid
    majority of code /can/ be written in a well-structured manner, for most languages.



    def register_additional_standard(self, managed_objects) :
    """
    registers additional standard interfaces that are not
    automatically installed at Connection creation time. Currently
    the only one is the object-manager interface, registered with

    «conn».register_additional_standard(managed_objects = True)
    """

    Note that Python’s indentation rules don’t apply to multiline string literals -- don’t you wish they did? So you end up with all that extra space within the literal. Do you see why I prefer to avoid that?

    No - or at least, it is very hard to comprehend why you might prefer the
    mess you gave. It is correct that Python multiline strings include any indentation in the strings. There are three possibilities here -
    sometimes you want the indents (and thus include them), sometimes you
    don't want them (and thus you align them at the left of the text), and sometimes you don't care (and thus put them wherever seems neatest).
    Most function docstrings fall into that third category, since they are
    mostly used as comments in the code and for the "help" command which
    ignores the leading indents.

    It is probably most common to have multiline docstrings at the left of
    the file. I have never before seen a silly mess with manual \n line
    breaks and line continuation characters, and I hope never to see it again.


    Line continuation characters in Python are usually an indicator of poor
    formatting, or an unhealthy obsession with line length limits.

    I like to keep within a line length limit of about 100 characters.


    That's a reasonable limit, but does not change my observation.

    I don't know if I am more experienced than you in Python (I may have
    been using Python for longer, but you may have worked with it more), but
    I would say that the "#end" comments directly detract from readability.

    Think about why you bother to indent code in languages where the compiler ignores such indentation anyway: it means you are expressing the structure
    of code in two different ways, one via statement brackets, and the other
    via indentation. This redundancy aids in understanding that the code does what you think it does.


    In languages with explicit blocking, the delimiters determine what the
    code does. The indents show the human reader what the code is supposed
    to do. These are, hopefully, the same thing - but they might not be.
    In Python, as there is only one source of blocking, there is no
    possibility of such an error (once you have ensured you have no mix of
    tabs and spaces).

    Redundancy is only a help if there is a way to automatically check and
    enforce consistency. Without that, redundancy can be worse than useless
    - if the two methods get out of sync, the casual reader will
    misunderstand the code, and the careful reader will see there is a
    problem but not know what it is.

    So for languages with explicit blocking, you need to be absolutely
    committed to keeping consistency, and use the tools you have - editors
    with automatic indents, gcc's "-Wmisleading-indentation" warning, and
    anything else to ease the cognitive burden and reduce the risk of inconsistencies.

    With Python, that is simply not an issue.


    (Another example of such redundancy is when people put comments saying
    what a piece of code does, rather than making the code itself clear.
    Changes to the code can easily lead to comments getting out of sync with
    the code, leading to confusion and misunderstanding.)


    Python gets rid of this redundancy, by having the compiler take notice of
    the whitespace and removing the statement bracketing symbols. So I put it back, by adding statement bracketing symbols that the compiler ignores.

    And that is worse than useless.

    At least with languages that have explicit block delimiters, the
    compiler will always have some checks on consistency. And tools (either compiler warnings, advanced editors, linters, etc.) can do more advanced checks. With comments, you have nothing.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 11:38:05 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 00:57, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 14:24:01 +0200, David Brown wrote:

    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()

    That looks unfinished to me. So I will add a "return" at the end (with
    a single tab indent, in this case).

    A redundant “return” ... kind of like my redundant “#end” comments, except
    yours work in a more restricted set of places ...

    Yes - the restriction is a major advantage. Python can check it, and
    there are far fewer ways for the programmer to get it wrong.


    Don't you ever just accept that a language is the way it is, and it is
    perfectly useable that way?

    Of course not.

    How silly. You should work to improve the things you can, instead of
    wasting effort arguing with brick walls. If you want to get involved in
    the design and future of a language, that's fine, but few people have
    the time and skills needed or the opportunity to do it as serious paid
    work. Getting worked up about the way Python blocking works is about as productive as getting worked up about the way English language spelling
    works. There are countless other more useful ways to spend your time -
    and certainly many more enjoyable ways.


    Or think that perhaps other people in the world know better than you do
    about how they want their language to work?

    And vice versa.

    It's not your language, so there is no "vice versa".


    Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and decided
    that making it the way they did was the best choice overall for the
    language they wanted?

    Barring a few obvious stupidities, yes of course they were, and are, smart people.

    When there are a number of smart, experienced and educated people
    involved in the decisions, "obvious stupidities" are extremely unlikely.
    That's the point of involving multiple people and gathering opinions
    from many in the field.

    There can be design decisions that don't suit /you/ - but they were not designing a language for /you/. There can be design decisions that made
    sense at the time, but turned out to be unwise in the end. Those are
    not "obvious stupidities", even with 20/20 hindsight. And there can be compromises where it is known that a decision is bad in at least some
    ways, because it allows other better things to be done - again, not a "stupidity" even if the one aspect in isolation looks bad.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.lang.misc on Fri Aug 30 14:59:08 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 01:49, Bart wrote:
    On 29/08/2024 13:24, David Brown wrote:
    On 28/08/2024 21:27, Bart wrote:
    On 28/08/2024 19:48, David Brown wrote:

    <snipping for brevity>

    It's just too 'open'. The contents of foo look like they're leaking into
    the rest of the program. As it is, someone looking at this in the future wanting to a a new statement to 'if a:' might think it ends before the comments since that 'anewstmt' is too far from the main body.

    It needs delimiters:


     def foo(a, b, c) :
          if a :
              if b :
                  if c :
                      doThis()
                  end
                  bnewstmt
               end

    # comment
    # comment
              anewstmt
          end
     end

    It does not /need/ delimiters.

    It does, sometimes, need a bit more care, especially if you have lots of nesting.

    (And again let me repeat - I prefer languages to have explicit
    delimiters. But that does not stop me being able to write Python code,
    or being happy with the language overall. There are a dozen things I
    dislike about Python, of which whitespace blocking is a very minor one,
    but there are many dozens more things I do like about it for the tasks
    for which I use the language.)


    Now you know that 'if a' doesn't end at that blank line, because no
    'end' has been seen for it.

    So I will add a "return" at the end (with a single tab indent, in this
    case).  If it is not the end of the function, I will sometimes use a
    "pass" to pull back the indent level.

    So you have problems too. Would you have needed 'return' if 'end's had
    been used in the original?

    I have, as I have said in several posts, added a "return" to make code clearer. I probably wouldn't have added them if Python had explicit
    block delimiters - I rarely have a plain "return" at the end of C
    functions (with no return type).

    But just because I sometimes add a "return" at the end of functions does
    not mean I see its use of indents for blocks as a problem. It's just different. And if an occasional "return" makes things clear, then the "problem" is solved simply and effortlessly, and is no longer a "problem".


    Of course, being a sane software developer, I do most of my
    programming using editors that are suitable for software development.
    Most professional carpenters use hammers for their nails, rather than
    bashing them in with stones - it's the same thing, really.


    And yet another, of more significance, if that after you've indented
    a block, it may now merge into an adjacent block that was already at
    that new indent. If you later need to revert that first block back to
    it's original position, you'd better make sure you mark that boundary.


    So mark the boundary.  Add a blank line.  Put a comment line
    describing the steps of the function.  You are making up problems for
    which you already have good solutions that you would be using in any
    programming language.

    How about just fixing the ******* language? That must be better than a million programmers wasting time creating their own fixes.

    Ah, so it is better to invalidate all the work done by these million programmers so far, along with all the tools, books, courses,
    documentation, etc., than to say that people writing big functions might
    want to add an occasional comment? Yes, I can see how that makes
    perfect sense.


    Having made your own language(s) gives you no more and no less right
    to comment about features of other languages that you like or dislike.


    I had my opinions even before I used my own stuff.


    Sure. We all have opinions about all sorts of things. Some people even
    have /informed/ opinions, that might be relevant to other people.

    One thing I despised was the begin-end business in Algol60 and Pascal,
    which has the same nuisance as braces in C-like languages.


    You don't like whitespace based blocks, and you don't like explicit
    delimiters for blocks. Maybe you just don't like structured
    programming? (Not all programming languages are structured.)

    I didn't like writing 'end else begin' any more than '} else {'. My
    stuff (and a few languages have picked up on it), uses just 'else',
    which also limits the placement possibilities when you have one token
    rather than three.


    Ah, it is the need to press a couple of extra keys that you despise so much?


    Your problem here is that you are obsessed with finding things that
    you want to see as misfeatures, design flaws, or problems in other
    languages

    Yes. I'm into language design. But I'm also interested in aspects of it
    that many disregard, such as microfeatures, or ease of deployment.


    That's great. But being interested in languages, their design, and
    their features does not mean having an obsession about calling their
    features "flaws".

    - and then obsess about how you can find new ways to make it more
    difficult to "work around" them.

    Fortunately I don't need to work with them much. If I did, I would find
    the means to make them tolerable.


    For someone who doesn't use programming languages much (other than
    perhaps your own ones), you certainly spend a lot of time complaining
    about them!


    Don't you ever just accept that a language is the way it is, and it is
    perfectly useable that way?

    Well, I used Fortran IV for a year. But presumably lots of people
    weren't that happy with it as we've since had Fortran 77, 90, 95, 2008,
    2018 and 2023.

    It's not just me!


    For every programmer involved in changing and developing the Fortran
    language, there are a thousand programmers who use it - whichever
    version of it they find best for their job. Now, it is important that
    these one-in-a-thousand programmers are there, improving the language.
    But most of us are in the 999-in-a-thousand group that /use/ the
    language. (In that one-in-a-thousand I am including the people who
    actively take part in discussions or proposals for changing the
    language, but not people who just moan about stuff in discussion groups.)

    Clearly you can take your own complaints seriously for your own
    languages, and they are very important to you personally. But in the
    grand scheme of things, they are utterly irrelevant to everyone else.
    So you are also in the 999-in-a-thousand group, just like everyone else
    here.

    Complaining about languages (or any kind of tool) doesn't change them -
    it doesn't do anything except make you less happy about using them.
    It's fine to discuss alternative ways to handle aspects of a language
    that you don't like, and to see if you can make it work better for your
    needs and preferences. It's fine to compare it to other languages, and
    see if there are alternatives that would suit you better. And sometimes having a rant is fun - after all, complaining (especially about the
    weather) is the national pastime for Brits. But mostly it is counter-productive.



      Or think that perhaps other people in the world know better than you
    do about how they want their language to work?  Has it never occurred
    to you that the people behind a given language - such as Python -
    considered various alternatives and decided that making it the way
    they did was the best choice overall for the language they wanted?

    Python is full of ill-advised choices. And it's become almost as much of
    a monster as C++, with a million incompatible features bolted on.


    So don't use it if you don't like it. Mushy peas are an ill-advised
    choice - I choose not to eat them, rather than to go to cookery groups
    and tell everyone how horrible they are.

    I'm not surprised that mere matters of syntax have low priority.


    As Bjarne Stustroup said, there are two kinds of programming languages
    - those that people complain about, and those that no one uses.


    Funny, I can complain about lots of languages that I never use!

    Yes, and no one takes your opinions seriously. Do you think there might
    be some reason for that?



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From vallor@vallor@cultnix.org to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 14:01:14 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 16:57:21 -0700, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote in <87zfou9926.fsf@nosuchdomain.example.com>:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    [...]
    Think about why you bother to indent code in languages where the
    compiler ignores such indentation anyway: it means you are expressing
    the structure of code in two different ways, one via statement
    brackets, and the other via indentation. This redundancy aids in
    understanding that the code does what you think it does.

    Python gets rid of this redundancy, by having the compiler take notice
    of the whitespace and removing the statement bracketing symbols. So I
    put it back, by adding statement bracketing symbols that the compiler
    ignores.

    You might find Bython useful.

    https://github.com/mathialo/bython

    (I don't, but you might.)

    Thank you for the pointer.

    (Had been wondering if there was something like "ratfor
    for python", and here it is. :) )
    --
    -v
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 14:33:31 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Thu, 29 Aug 2024 18:44:35 +0200, Janis Papanagnou wrote:

    Vim is an editor that has the most simple and also very powerful
    indenting for well structured data and programs I've yet seen. (Not
    mentioning its equally powerful other editing facilities.)

    Vim is only good for text-editing, though

    Again, L'D'O' is wrong.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.lang.misc on Fri Aug 30 15:55:36 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 13:59, David Brown wrote:
    On 30/08/2024 01:49, Bart wrote:
    On 29/08/2024 13:24, David Brown wrote:
    On 28/08/2024 21:27, Bart wrote:
    On 28/08/2024 19:48, David Brown wrote:

    <snipping for brevity>

    It's just too 'open'. The contents of foo look like they're leaking
    into the rest of the program. As it is, someone looking at this in the
    future wanting to a a new statement to 'if a:' might think it ends
    before the comments since that 'anewstmt' is too far from the main body.

    It needs delimiters:


      def foo(a, b, c) :
           if a :
               if b :
                   if c :
                       doThis()
                   end
                   bnewstmt
                end

    # comment
    # comment
               anewstmt
           end
      end

    It does not /need/ delimiters.

    There's lot of things that language syntax might not need. For example,
    I could dispense with the closing parentheses here:

    x = (a + (b + (c + d

    as they can supplied as needed at end-of-line. But it's much better idea
    to supply them for all sorts of reasons.

    (My Casio calculator allows such parentheses to be left out.)

    It does, sometimes, need a bit more care, especially if you have lots of nesting.

    A /lot/ more care.

    (And again let me repeat - I prefer languages to have explicit
    delimiters.  But that does not stop me being able to write Python code,
    or being happy with the language overall.  There are a dozen things I dislike about Python, of which whitespace blocking is a very minor one,
    but there are many dozens more things I do like about it for the tasks
    for which I use the language.)

    I just find the syntax fragile.

    How about just fixing the ******* language? That must be better than a
    million programmers wasting time creating their own fixes.

    Ah, so it is better to invalidate all the work done by these million programmers so far, along with all the tools, books, courses,
    documentation, etc., than to say that people writing big functions might want to add an occasional comment?  Yes, I can see how that makes
    perfect sense.

    If you're going fix it, then fix up, and not wait 30+ years to do so!

    But there can be ways to do it without needing to change existing code
    or tools.


    Having made your own language(s) gives you no more and no less right
    to comment about features of other languages that you like or dislike.


    I had my opinions even before I used my own stuff.


    Sure.  We all have opinions about all sorts of things.  Some people even have /informed/ opinions, that might be relevant to other people.

    One thing I despised was the begin-end business in Algol60 and Pascal,
    which has the same nuisance as braces in C-like languages.


    You don't like whitespace based blocks, and you don't like explicit delimiters for blocks.  Maybe you just don't like structured
    programming?  (Not all programming languages are structured.)

    Both brace-style (and especially C-style optional braces) and
    indent-based have their problems.


    I didn't like writing 'end else begin' any more than '} else {'. My
    stuff (and a few languages have picked up on it), uses just 'else',
    which also limits the placement possibilities when you have one token
    rather than three.


    Ah, it is the need to press a couple of extra keys that you despise so
    much?

    no, it's just poor ergonomics. Language designers must have thought it
    neat to allow only a single statement for function bodies, loop bodies,
    or branches of conditional code.

    If someone wanted more than one statement, they wrapped them inside a 'compound' statement (and hence you ended up with conditional '{-}' and conditional 'begin-end'.

    But look at these examples:

    if (cond) {s1; s2;} else {s3; s4;}
    if cond then begin s1; s2 end else begin s3; s4 end

    It's clear that those first sets of block delimiters are not needed: s1
    and s2 are already delimited by ') ... else' or 'then ... else'.

    A delimiter is only really needed at the end of the final 'else' block:

    if (cond) s1; s2; else s3; s4;}
    if cond then s1; s2 else s3; s4 end

    With the second line, it works (this is what Algol68 introduced, and
    what I copied).

    But that first line looks weird with its unbalanced closing }. There can
    also be a problem if you wanted to dispense with the brackets around
    '(cond)', as now 'cond' runs into 's1'.

    So C-style syntax is not an easy fix; better to leave it.

    Note that Python does use block delimiters in some cases:

    if cond:
    s1
    s2
    else
    s3
    s4

    Like the 'else' here. It is the one for the final block that is missing.

    Yes. I'm into language design. But I'm also interested in aspects of
    it that many disregard, such as microfeatures, or ease of deployment.


    That's great.  But being interested in languages, their design, and
    their features does not mean having an obsession about calling their features "flaws".

    Are you saying that no language (C for example) has flaws?

    If not, then why can't I call them flaws?

    It's not just me!


    For every programmer involved in changing and developing the Fortran language, there are a thousand programmers who use it - whichever
    version of it they find best for their job.  Now, it is important that these one-in-a-thousand programmers are there, improving the language.
    But most of us are in the 999-in-a-thousand group that /use/ the
    language.  (In that one-in-a-thousand I am including the people who actively take part in discussions or proposals for changing the
    language, but not people who just moan about stuff in discussion groups.)

    So I don't count?

    Apparently I'm in the 999/1000 group even though I don't use those
    languages. But I can't be in the 1/1000 group because I'm not involved
    in those languages.

    So I guess I'm nowhere.

    Clearly you can take your own complaints seriously for your own
    languages, and they are very important to you personally.  But in the
    grand scheme of things, they are utterly irrelevant to everyone else. So
    you are also in the 999-in-a-thousand group, just like everyone else here.

    Not really. You just want to belittle the stuff I do.

    Pretty much everything I've complained about in a mainstream language,
    is something that I've fixed in my own products. So I know much work
    that was to do, how well it worked, or whether it failed, or if I
    decided it wasn't worthwhile.

    People in the 999/1000 group don't normally run their own languages, or
    manage their own implementations of existing languages, to try such experiments.

    In my case the experiment has been running since 1982.



    Complaining about languages (or any kind of tool) doesn't change them -
    it doesn't do anything except make you less happy about using them. It's fine to discuss alternative ways to handle aspects of a language that
    you don't like, and to see if you can make it work better for your needs
    and preferences.  It's fine to compare it to other languages, and see if there are alternatives that would suit you better.  And sometimes having
    a rant is fun - after all, complaining (especially about the weather) is
    the national pastime for Brits.  But mostly it is counter-productive.

    You still get it. I can actually change my 'weather'! You're just jealous.

    Python is full of ill-advised choices. And it's become almost as much
    of a monster as C++, with a million incompatible features bolted on.


    So don't use it if you don't like it.  Mushy peas are an ill-advised
    choice - I choose not to eat them, rather than to go to cookery groups
    and tell everyone how horrible they are.

    This isn't a Python group nor a C group. Any language can be discussed including private ones.


    Funny, I can complain about lots of languages that I never use!

    Yes, and no one takes your opinions seriously.  Do you think there might
    be some reason for that?

    You don't, certainly.

    I have to keep reminding you, the stuff I do isn't just mouthing off, it
    is actually implementing things. And it's not just toy hobbyist stuff
    either, it's *what I used to earn a living*.

    Even last century I could write stuff like this:

    [10]int a, b

    a := b

    This copies array b to a. Even after 50 years, C can't do this, you have
    to write (AFTER including string.h, jesus..):

    memcpy(a, b, sizeof(a)/sizeof(a[0]));

    But here a compiler can't check that a and b are the same size, or even
    of the same type! Nor can it check I've supplied the right size.

    According to you however, I'm not allowed to point out such shortcomings
    or 'flaws' in a language, because I don't have any clout.

    So, the flaws don't exist, or do they only exist if that 1/1000 Alpha individual says they do?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From John Ames@commodorejohn@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 08:14:21 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 21:27:36 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    /All/ languages, except perhaps Bart's private language that is only
    used by him, have their annoyances. I have worked at least a little
    with a fair number of languages, and I've never seen one that I
    thought was "perfect". But different people have different things
    that the like and dislike about any given language.

    So if you have the choice of which language to use (many programmers
    do not), you pick one that has more things you like for the task in
    question in comparison to the things you don't like.

    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just
    weird.

    But it's important to understand that these are opinions - the
    designers of Python were /not/ stupid to have made the language that
    way. They just had different opinions from you, and the had a much
    better basis for forming those opinions than you or I.

    Yeah, well, your opinion that my opinion is just, like, my opinion is
    just, like, your opinion, man.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From John Ames@commodorejohn@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 08:28:35 2024
    From Newsgroup: comp.lang.misc

    On Fri, 30 Aug 2024 11:38:05 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    Getting worked up about the way Python blocking works is about as
    productive as getting worked up about the way English language
    spelling works. There are countless other more useful ways to spend
    your time - and certainly many more enjoyable ways.

    Some people actually enjoy arguing on the Internet, y'know.

    When there are a number of smart, experienced and educated people
    involved in the decisions, "obvious stupidities" are extremely
    unlikely. That's the point of involving multiple people and gathering opinions from many in the field.

    You may consider it as "unlikely" as you wish, but the fact is that
    literal whitespace has been considered Obviously Stupid in the computer- programming world for so long that it was the subject of a joke re: JCL
    in "Real Programmers Don't Use Pascal," published in 1983.

    That's not to say that "considered Obviously Stupid" is the same thing
    as "objectively wrong" - but if your argument is that all of this is on
    equal footing as Just Opinions, discounting decades of established
    opinion across the industry in preference to the opinions of the subset
    of Python developers & advocates who believe in literal whitespace as Unambiguously Good rather gives the lie to that.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 18:42:33 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 17:14, John Ames wrote:
    On Thu, 29 Aug 2024 21:27:36 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    /All/ languages, except perhaps Bart's private language that is only
    used by him, have their annoyances. I have worked at least a little
    with a fair number of languages, and I've never seen one that I
    thought was "perfect". But different people have different things
    that the like and dislike about any given language.

    So if you have the choice of which language to use (many programmers
    do not), you pick one that has more things you like for the task in
    question in comparison to the things you don't like.

    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just weird.

    (I gather the politically correct response to that is "I'm not weird -
    /you/ are weird" :-) )

    There's a difference between critiquing something and saying the
    language designers were stupid. I can say I prefer explicit blocking delimiters. I can give reasons why I think those are better than
    white-space based blocks. But to have any kind of useful discussion,
    you need to be able to consider what advantages the alternatives have,
    and think about why some people might have different opinions. Writing
    "I get lost with white-space indentation and have to add lots of
    comments - therefore the language is flawed and the designers made
    stupid decisions" is not helpful critique - it's just ranting.

    Of course you will find things you dislike about any language you use.
    And discussing those things, and ways to mitigate their impact, is also
    fine. It's the "this language is fundamentally flawed because /I/
    dislike a particular aspect of it" attitude I disagree with.


    But it's important to understand that these are opinions - the
    designers of Python were /not/ stupid to have made the language that
    way. They just had different opinions from you, and the had a much
    better basis for forming those opinions than you or I.

    Yeah, well, your opinion that my opinion is just, like, my opinion is
    just, like, your opinion, man.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 18:54:54 2024
    From Newsgroup: comp.lang.misc

    On 30/08/2024 17:28, John Ames wrote:
    On Fri, 30 Aug 2024 11:38:05 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    Getting worked up about the way Python blocking works is about as
    productive as getting worked up about the way English language
    spelling works. There are countless other more useful ways to spend
    your time - and certainly many more enjoyable ways.

    Some people actually enjoy arguing on the Internet, y'know.

    Up to a point, I agree. Where would the internet be without arguments?
    Cat videos and porn, I suppose.

    But sometimes I think discussions could be a little more informative and
    a little less repetitive ranting. Occasionally it is also nice to learn something new from the internet. (I actually learned from this thread
    that Python 3 is better at checking for mixed tabs and spaces than
    Python 2 was.)


    When there are a number of smart, experienced and educated people
    involved in the decisions, "obvious stupidities" are extremely
    unlikely. That's the point of involving multiple people and gathering
    opinions from many in the field.

    You may consider it as "unlikely" as you wish, but the fact is that
    literal whitespace has been considered Obviously Stupid in the computer- programming world for so long that it was the subject of a joke re: JCL
    in "Real Programmers Don't Use Pascal," published in 1983.

    That's not to say that "considered Obviously Stupid" is the same thing
    as "objectively wrong" - but if your argument is that all of this is on
    equal footing as Just Opinions, discounting decades of established
    opinion across the industry in preference to the opinions of the subset
    of Python developers & advocates who believe in literal whitespace as Unambiguously Good rather gives the lie to that.


    Python is a hugely popular language, with whitespace for blocks. C, C++
    and Java are hugely poplar languages with braces as delimiters. I don't
    see how anyone can get an "established opinion" from that.

    But to be fair, the worst case of significant whitespace /was/ obviously stupid - that is makefiles treating tabs and spaces differently. The
    original author of make said himself that it was a daft idea, but unfortunately the utility took off in popularity so quickly that it
    could not be rectified.



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 19:17:47 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 21:36:08 +0200
    David Brown <david.brown@hesbynett.no> gabbled:
    On 29/08/2024 18:44, Janis Papanagnou wrote:
    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.

    LOL. (You appear to be joking. - If not, continue reading...)


    I was not joking.

    But what makes you think that his needs are not covered by Vim?

    You seem to have missed the point - sorry if I was not clear.

    The irony :)


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 19:20:10 2024
    From Newsgroup: comp.lang.misc

    On Fri, 30 Aug 2024 08:14:21 -0700
    John Ames <commodorejohn@gmail.com> gabbled:
    On Thu, 29 Aug 2024 21:27:36 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    /All/ languages, except perhaps Bart's private language that is only
    used by him, have their annoyances. I have worked at least a little
    with a fair number of languages, and I've never seen one that I
    thought was "perfect". But different people have different things
    that the like and dislike about any given language.

    So if you have the choice of which language to use (many programmers
    do not), you pick one that has more things you like for the task in
    question in comparison to the things you don't like.

    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just >weird.

    Some insecure people feel an attack on their favourite language is some kind
    of attack or slight against them personally. Its a pathetic and juvenile trait that unfortunately is found a lot amongst IT types.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nospam@nospam@example.net to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 23:36:07 2024
    From Newsgroup: comp.lang.misc



    On Fri, 30 Aug 2024, Scott Lurndal wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Thu, 29 Aug 2024 18:44:35 +0200, Janis Papanagnou wrote:

    Vim is an editor that has the most simple and also very powerful
    indenting for well structured data and programs I've yet seen. (Not
    mentioning its equally powerful other editing facilities.)

    Vim is only good for text-editing, though

    Again, L'D'O' is wrong.


    This is the truth! Nothing of value in his posts.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 23:42:31 2024
    From Newsgroup: comp.lang.misc

    On Fri, 30 Aug 2024 11:38:05 +0200, David Brown wrote:

    You should work to improve the things you can, instead of
    wasting effort arguing with brick walls.

    Which is exactly what I have been doing. You are just another of those
    trying to dispute my techniques.

    It's not your language, so there is no "vice versa".

    It’s open source. It’s *everybody*’s language.

    Barring a few obvious stupidities, yes of course they were, and are,
    smart people.

    When there are a number of smart, experienced and educated people
    involved in the decisions, "obvious stupidities" are extremely unlikely.

    Now I know you haven’t used Python that much.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 23:49:51 2024
    From Newsgroup: comp.lang.misc

    On Thu, 29 Aug 2024 14:05:41 +0200, David Brown wrote:

    ... put in so much extra
    crap and silliness that readers get caught up in that instead of
    noticing that most of the function is meaningless.

    Interesting. Now you are trying to claim that, because you don’t
    understand what the code does, that makes it somehow “meaningless”?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 23:52:12 2024
    From Newsgroup: comp.lang.misc

    On Wed, 28 Aug 2024 19:19:38 -0700, Keith Thompson wrote:

    My impression is that your unconventional style indicates a relative
    lack of experience in Python.

    You think maybe I should practise by writing more Python code?

    OK, how about your thoughts on comparing this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)

    with this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.lang.misc on Sat Aug 31 00:00:17 2024
    From Newsgroup: comp.lang.misc

    On Fri, 30 Aug 2024 15:55:36 +0100, Bart wrote:

    There's lot of things that language syntax might not need. For example,
    I could dispense with the closing parentheses here:

    x = (a + (b + (c + d

    as they can supplied as needed at end-of-line.

    Then you can’t continue an expression across multiple lines.

    There was one language vaguely I recall (might have been a Lisp dialect)
    where a single “]” would be interpreted as closing all currently-unmatched “(”. Scheme, I believe, realizes that long lines of “))))” just make the
    (human) reader’s eyes glaze over, so they allow “[” and “]” with the same
    meanings as “(” and “)”, but you must pair like with like. As if “)])]” is
    much of an improvement.

    People can, and do, experiment with many different ideas in programming languages.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 21:37:09 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 19:19:38 -0700, Keith Thompson wrote:
    My impression is that your unconventional style indicates a relative
    lack of experience in Python.

    You think maybe I should practise by writing more Python code?

    And you snipped the part where I acknowledged that might be an invalid conclusion. I have no opinion on what you should do.

    OK, how about your thoughts on comparing this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)

    with this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)

    The difference is obvious: the second calls attrs.append() even if attr
    is None. I don't know what point you're trying to make.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Aug 30 21:39:15 2024
    From Newsgroup: comp.lang.misc

    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 19:19:38 -0700, Keith Thompson wrote:
    My impression is that your unconventional style indicates a relative
    lack of experience in Python.

    You think maybe I should practise by writing more Python code?

    And you snipped the part where I acknowledged that might be an invalid conclusion. I have no opinion on what you should do.

    Let me amend that slightly. I suggest that you'd be better off writing idiomatic Python code, at least if you want to share that code with
    others. You are of course under no obligation to follow my advice, and
    I won't spend any more time trying to persuade you.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bart@bc@freeuk.com to comp.lang.misc on Sat Aug 31 10:51:45 2024
    From Newsgroup: comp.lang.misc

    On 31/08/2024 05:37, Keith Thompson wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Wed, 28 Aug 2024 19:19:38 -0700, Keith Thompson wrote:
    My impression is that your unconventional style indicates a relative
    lack of experience in Python.

    You think maybe I should practise by writing more Python code?

    And you snipped the part where I acknowledged that might be an invalid conclusion. I have no opinion on what you should do.

    OK, how about your thoughts on comparing this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)

    with this

    for attrname in obj.tag_attrs :
    attr = getattr(obj, attrname)
    if attr != None :
    if isinstance(attr, enum.Enum) :
    attr = attr.value
    elif isinstance(attr, Type) :
    attr = unparse_signature(attr)
    elif not isinstance(attr, str) :
    raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr)))
    attrs.append("%s=%s" % (attrname, quote_xml_attr(attr)))
    out.write(" " * indent + "<" + tag_name)

    The difference is obvious: the second calls attrs.append() even if attr
    is None. I don't know what point you're trying to make.


    Was it? I was convinced he'd posted exactly the same code by mistake,
    even though my brain told me there something that about them that didn't match. It took me nearly a minute to spot the difference.

    I don't know how much quicker it would have been with 'end' delimiters,
    but then the versions would have been:

    end
    A...
    end

    and:
    end
    end
    A...

    instead of:

    A...
    and:

    A...

    Disregarding indentation, it's (end, A, end) vs (end, end A) instead of
    (A) and (A).

    I think it would have been more obvious than with no 'end's.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Aug 31 17:06:05 2024
    From Newsgroup: comp.lang.misc

    On 31/08/2024 01:49, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 14:05:41 +0200, David Brown wrote:

    ... put in so much extra
    crap and silliness that readers get caught up in that instead of
    noticing that most of the function is meaningless.

    Interesting. Now you are trying to claim that, because you don’t
    understand what the code does, that makes it somehow “meaningless”?

    I covered that in an earlier post. If you didn't bother reading it
    earlier, why should I bother posting it again?

    To be fair, it's possible that what you posted was only part of a real function.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Sep 3 00:09:17 2024
    From Newsgroup: comp.lang.misc

    On Sat, 31 Aug 2024 17:06:05 +0200, David Brown wrote:

    On 31/08/2024 01:49, Lawrence D'Oliveiro wrote:

    Interesting. Now you are trying to claim that, because you don’t
    understand what the code does, that makes it somehow “meaningless”?

    I covered that in an earlier post.

    Maybe in your mind you thought you did. Nowhere in your comments on this
    code did you say so, that I can find.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Sep 3 10:46:55 2024
    From Newsgroup: comp.lang.misc

    On 03/09/2024 02:09, Lawrence D'Oliveiro wrote:
    On Sat, 31 Aug 2024 17:06:05 +0200, David Brown wrote:

    On 31/08/2024 01:49, Lawrence D'Oliveiro wrote:

    Interesting. Now you are trying to claim that, because you don’t
    understand what the code does, that makes it somehow “meaningless”?

    I covered that in an earlier post.

    Maybe in your mind you thought you did. Nowhere in your comments on this
    code did you say so, that I can find.

    To be accurate, the code in question was not actually /meaningless/ - it
    was merely pointlessly complex, inefficient and unclear.

    You wrote:

    def register_additional_standard(self, **kwargs) :
    for key in kwargs :
    if kwargs[key] :
    if key == "managed_objects" :
    # ....
    else :
    raise TypeError("unrecognized argument keyword
    “%s”" % key)


    I changed it in a re-write to:

    def register_additional_standard(self, managed_objects) :
    if managed_objects :
    # ....


    That change, I think, was lost in the discussions about bizarre
    formatting practices.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Tue Sep 3 21:56:36 2024
    From Newsgroup: comp.lang.misc

    On Tue, 3 Sep 2024 10:46:55 +0200, David Brown wrote:

    I changed it in a re-write to:

    def register_additional_standard(self, managed_objects) :
    if managed_objects :
    # ....

    My original was meant with future extensibility in mind. That was made
    clear in the docstring. You *did* read the docstring, didn’t you?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Wed Sep 4 09:30:39 2024
    From Newsgroup: comp.lang.misc

    On 03/09/2024 23:56, Lawrence D'Oliveiro wrote:
    On Tue, 3 Sep 2024 10:46:55 +0200, David Brown wrote:

    I changed it in a re-write to:

    def register_additional_standard(self, managed_objects) :
    if managed_objects :
    # ....

    My original was meant with future extensibility in mind. That was made
    clear in the docstring. You *did* read the docstring, didn’t you?

    Even if it was intended to be extendable, it would still be a /very/
    silly way to write the code.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From candycanearter07@candycanearter07@candycanearter07.nomail.afraid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 7 18:30:03 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 22:57 this Thursday (GMT):
    On Thu, 29 Aug 2024 14:24:01 +0200, David Brown wrote:

    def foo(a, b, c) :
    if a :
    if b :
    if c :
    doThis()

    That looks unfinished to me. So I will add a "return" at the end (with
    a single tab indent, in this case).

    A redundant “return” ... kind of like my redundant “#end” comments, except
    yours work in a more restricted set of places ...

    Don't you ever just accept that a language is the way it is, and it is
    perfectly useable that way?

    Of course not.

    Or think that perhaps other people in the world know better than you do
    about how they want their language to work?

    And vice versa.

    Has it never occurred to you that the people behind a given
    language - such as Python - considered various alternatives and decided
    that making it the way they did was the best choice overall for the
    language they wanted?

    Barring a few obvious stupidities, yes of course they were, and are, smart people.


    Subjectively, I prefer early returns over nested ifs:

    def foo(a, b, c):
    if !a: return
    if !b: return
    if !c: return

    doThis()
    --
    user <candycane> is generated from /dev/urandom
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 7 22:48:10 2024
    From Newsgroup: comp.lang.misc

    On Sat, 7 Sep 2024 18:30:03 -0000 (UTC), candycanearter07 wrote:

    Subjectively, I prefer early returns over nested ifs:

    Nested ifs nest, early returns don’t.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 09:59:46 2024
    From Newsgroup: comp.lang.misc

    On 29.08.2024 21:36, David Brown wrote:
    On 29/08/2024 18:44, Janis Papanagnou wrote:
    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.
    [...]

    But what makes you think that his needs are not covered by Vim?

    You seem to have missed the point - sorry if I was not clear.

    He complained that he didn't want to learn complicated macros in Vim
    just to be able to indent or un-indent lines of code. The solution is obvious - he should use an editor other than Vim.

    This is not what I'd call a solution. I'd call it elusion; and in both
    senses - if he didn't use his editor for that space-indenting because
    he doesn't know how to do it he could look that up, but it is not any
    issue to do that, only more laborious than indenting brace structures,
    and the suggestion to switch to another tool is also elusive because
    it doesn't address the issue (he would still have to learn how to do
    it in any other tool). - But that was not the point.


    He could, of course, learn how to use Vim. It's a perfectly good editor
    with a lot of features. [...]

    The point was about language design and (well known) problems with a
    design that uses white-space for semantical purposes. That the brace
    structures can usually be edited in better, simpler ways (beyond also
    providing safety etc. using a more sophisticated designed language).


    There are more than enough decent editors to choose from, that cover the basic needs of programmers. Some people use one editor for everything, others use a range for different purposes - whatever suits you. But it
    is pretty absurd to complain that it is difficult to indent code just
    because you (i.e., Muttley) think it is hard to do in one particular
    editor.

    As said; it was about "the language was designed properly"[Muttley].
    And saying that switching the editor would solve something here is
    just missing the point.

    You can (also in Vim) write macros, as you correctly imply, or do
    all the things that you can do with "other tools" (but only equally
    laborious as in these other tools) as I already said. You can also
    (for that specific IMO mis-designed language) enable "folding" (by
    spaces) in Vim to not have to write macros (and not littering the
    standard editor environment) that makes it comparably simply to do
    the indentation more comfortably with less keystrokes. But nothing
    beats the editing of parenthesized structures. (And doesn't change
    any language mis-design.) YMMV.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 10:06:12 2024
    From Newsgroup: comp.lang.misc

    On 30.08.2024 04:53, Lawrence D'Oliveiro wrote:
    On Thu, 29 Aug 2024 18:44:35 +0200, Janis Papanagnou wrote:

    Vim is an editor that has the most simple and also very powerful
    indenting for well structured data and programs I've yet seen. (Not
    mentioning its equally powerful other editing facilities.)

    Vim is only good for text-editing, though.

    "Only"? - Yes, Vim is a text-editor. (With only few functions beyond.)
    And it does that in an excellent most efficient way I've not yet seen
    in any other text editor. (Exactly what I need for universal editing
    of any text. YMMV.)

    It assumes a file is split into
    lines. Emacs makes no such assumption, and can also edit non-text files.

    You have obviously no clue.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 10:16:35 2024
    From Newsgroup: comp.lang.misc

    On 30.08.2024 21:20, Muttley@dastardlyhq.com wrote:
    On Fri, 30 Aug 2024 08:14:21 -0700
    John Ames <commodorejohn@gmail.com> gabbled:
    [...]
    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just
    weird.

    Some insecure people feel an attack on their favourite language is some kind of attack or slight against them personally. Its a pathetic and juvenile trait
    that unfortunately is found a lot amongst IT types.

    It's not restricted to languages or IT-stuff; you can see it with
    books or films or music or political or religious preferences...

    In IT we had as well various "wars" in the past. More considerate
    folks avoid such wars (and respect diversity of thoughts/opinions
    and preferences) by focusing on the facts alone. Other folks feel
    an urge to (unnecessarily) ignite them.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 09:25:23 2024
    From Newsgroup: comp.lang.misc

    On Sat, 14 Sep 2024 10:16:35 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> gabbled:
    On 30.08.2024 21:20, Muttley@dastardlyhq.com wrote:
    On Fri, 30 Aug 2024 08:14:21 -0700
    John Ames <commodorejohn@gmail.com> gabbled:
    [...]
    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just
    weird.

    Some insecure people feel an attack on their favourite language is some kind >> of attack or slight against them personally. Its a pathetic and juvenile >trait
    that unfortunately is found a lot amongst IT types.

    It's not restricted to languages or IT-stuff; you can see it with
    books or films or music or political or religious preferences...

    True. Usually people with fragile egos and/or low self esteem who validate themselves via some belief or preference.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 09:34:35 2024
    From Newsgroup: comp.lang.misc

    On Sat, 14 Sep 2024 10:06:12 +0200, Janis Papanagnou wrote:

    On 30.08.2024 04:53, Lawrence D'Oliveiro wrote:

    Emacs makes no such assumption, and can also edit non-text files.

    You have obviously no clue.

    I have actually used it for that. That’s my “clue” to you.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 19:10:06 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Sat, 14 Sep 2024 10:06:12 +0200, Janis Papanagnou wrote:

    On 30.08.2024 04:53, Lawrence D'Oliveiro wrote:

    Emacs makes no such assumption, and can also edit non-text files.

    You have obviously no clue.

    I have actually used it for that. That’s my “clue” to you.

    You elided context to make a bogus point. Typical.

    On 30.08.2024 04:53, Lawrence D'Oliveiro wrote:

    LDO: >> Vim is only good for text-editing, though.


    Janis:> You have obviously no clue.

    Janis is correct, you have no clue

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it possible to edit a binary or executable file.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sat Sep 14 22:25:53 2024
    From Newsgroup: comp.lang.misc

    On Sat, 14 Sep 2024 19:10:06 GMT, Scott Lurndal wrote:

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it
    possible to edit a binary or executable file.

    Wow, a special mode just to edit binary files, when Emacs can do it in
    its regular mode.

    More on vim’s “binary” mode here <https://vi.stackexchange.com/questions/343/how-to-edit-binary-files-with-vim>: It just sets a bunch of options to minimize the chance of screwing up
    the file in ways you don’t want. Apart from that, it’s still editing
    it as a text file.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 09:06:51 2024
    From Newsgroup: comp.lang.misc

    On Sat, 14 Sep 2024 22:25:53 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boringly babbled:
    On Sat, 14 Sep 2024 19:10:06 GMT, Scott Lurndal wrote:

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it
    possible to edit a binary or executable file.

    Wow, a special mode just to edit binary files, when Emacs can do it in
    its regular mode.

    The 1980s phoned, they want their editor wars back.

    It just sets a bunch of options to minimize the chance of screwing up
    the file in ways you don’t want. Apart from that, it’s still editing
    it as a text file.

    Any sane person uses a dedicated hex editor to edit binary files, not vim
    or emacs.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 15:51:16 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Sat, 14 Sep 2024 19:10:06 GMT, Scott Lurndal wrote:

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it
    possible to edit a binary or executable file.

    Wow, a special mode just to edit binary files

    So, you admit you were wrong. You again elided the con-text that showed
    you were incorrect. Dishonest of you, to be sure, yet typical of your
    posts.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 15:54:01 2024
    From Newsgroup: comp.lang.misc

    On 2024-09-14, Scott Lurndal <scott@slp53.sl.home> wrote:
    LDO: >> Vim is only good for text-editing, though.


    Janis:> You have obviously no clue.

    Janis is correct, you have no clue

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it possible to edit a binary or executable file.

    I use Vim for dynamically syntax-coloring code served by CGIT.

    You heard right.

    When CGIT presents code out of a repository, it calls a script
    in order to convert it to colorized HTML. That script can be customized.

    Mine uses expect to run Vim to load the file, set a few settings, and
    invoke the :TOhtml command to dump HTML.

    That is then post-proocessed to remove the inline style sheet. The web
    page it gets embedded into has its own CSS rules for the Vim-generated
    HTML tags.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 21:43:42 2024
    From Newsgroup: comp.lang.misc

    On 14/09/2024 10:16, Janis Papanagnou wrote:
    On 30.08.2024 21:20, Muttley@dastardlyhq.com wrote:
    On Fri, 30 Aug 2024 08:14:21 -0700
    John Ames <commodorejohn@gmail.com> gabbled:
    [...]
    Sure - but picking one that best suits your needs doesn't mean you
    can't critique its annoyances/flaws. This team-sports mentality is just
    weird.

    Some insecure people feel an attack on their favourite language is some kind >> of attack or slight against them personally. Its a pathetic and juvenile trait
    that unfortunately is found a lot amongst IT types.

    It's not restricted to languages or IT-stuff; you can see it with
    books or films or music or political or religious preferences...

    In IT we had as well various "wars" in the past. More considerate
    folks avoid such wars (and respect diversity of thoughts/opinions
    and preferences) by focusing on the facts alone. Other folks feel
    an urge to (unnecessarily) ignite them.


    Fair enough. I apologise for igniting Muttley.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Brown@david.brown@hesbynett.no to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 21:47:13 2024
    From Newsgroup: comp.lang.misc

    On 14/09/2024 09:59, Janis Papanagnou wrote:
    On 29.08.2024 21:36, David Brown wrote:
    On 29/08/2024 18:44, Janis Papanagnou wrote:
    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.
    [...]

    But what makes you think that his needs are not covered by Vim?

    You seem to have missed the point - sorry if I was not clear.

    He complained that he didn't want to learn complicated macros in Vim
    just to be able to indent or un-indent lines of code. The solution is
    obvious - he should use an editor other than Vim.

    This is not what I'd call a solution. I'd call it elusion; and in both
    senses - if he didn't use his editor for that space-indenting because
    he doesn't know how to do it he could look that up, but it is not any
    issue to do that, only more laborious than indenting brace structures,
    and the suggestion to switch to another tool is also elusive because
    it doesn't address the issue (he would still have to learn how to do
    it in any other tool). - But that was not the point.


    This thread died out two weeks ago, and should have been left there.


    I didn't suggest he switch to a different tool - I suggested he /didn't/ switch to a tool that he didn't want to learn. But I do think it is
    worth learning some of the basic features of the tools you use regularly.

    That is all completely independent of what anyone likes or dislikes
    about a particular aspect of any particular language.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nospam@nospam@example.net to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 21:55:05 2024
    From Newsgroup: comp.lang.misc



    On Sun, 15 Sep 2024, Scott Lurndal wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Sat, 14 Sep 2024 19:10:06 GMT, Scott Lurndal wrote:

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it >>> possible to edit a binary or executable file.

    Wow, a special mode just to edit binary files

    So, you admit you were wrong. You again elided the con-text that showed
    you were incorrect. Dishonest of you, to be sure, yet typical of your
    posts.


    This is Lawrence, and that is his bread and butter. Just killfile and move
    on.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Sun Sep 15 21:32:21 2024
    From Newsgroup: comp.lang.misc

    On Sun, 15 Sep 2024 15:51:16 GMT, Scott Lurndal wrote:

    You again elided the con-text that showed you were incorrect.

    You left out this:

    More on vim’s “binary” mode here <https://vi.stackexchange.com/questions/343/how-to-edit-binary-files-with- vim>:
    It just sets a bunch of options to minimize the chance of screwing up the
    file in ways you don’t want. Apart from that, it’s still editing it as a text file.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 16 07:27:40 2024
    From Newsgroup: comp.lang.misc

    On Sun, 15 Sep 2024 21:47:13 +0200
    David Brown <david.brown@hesbynett.no> boringly babbled:
    On 14/09/2024 09:59, Janis Papanagnou wrote:
    On 29.08.2024 21:36, David Brown wrote:
    On 29/08/2024 18:44, Janis Papanagnou wrote:
    On 29.08.2024 14:30, David Brown wrote:
    On 29/08/2024 09:28, Muttley@dastardlyhq.com wrote:
    [...]

    Then don't use vim - use an editor that suits your needs.
    [...]

    But what makes you think that his needs are not covered by Vim?

    You seem to have missed the point - sorry if I was not clear.

    He complained that he didn't want to learn complicated macros in Vim
    just to be able to indent or un-indent lines of code. The solution is
    obvious - he should use an editor other than Vim.

    This is not what I'd call a solution. I'd call it elusion; and in both
    senses - if he didn't use his editor for that space-indenting because
    he doesn't know how to do it he could look that up, but it is not any
    issue to do that, only more laborious than indenting brace structures,
    and the suggestion to switch to another tool is also elusive because
    it doesn't address the issue (he would still have to learn how to do
    it in any other tool). - But that was not the point.


    This thread died out two weeks ago, and should have been left there.

    To be fair it should have been left in the 1990s.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 16 17:28:07 2024
    From Newsgroup: comp.lang.misc

    On 15.09.2024 11:06, Muttley@dastardlyhq.com wrote:
    On Sat, 14 Sep 2024 22:25:53 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boringly babbled:
    [...]

    Any sane person uses a dedicated hex editor to edit binary files, not vim
    or emacs.

    I suppose you may be right. (Or maybe not?)

    Frankly, I rarely edited binary files [with any editor]; for me
    that's at best a corner case, and at worst a wrong approach (in
    some cases I've seen).

    But, to be honest, in the few cases where I did binary editings
    I was glad that I could just use the editor I'm used to. And in
    such cases I resorted to :!xxd ... sort of data handling from
    within the editor I use (Vi/Vim).

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 16 17:30:12 2024
    From Newsgroup: comp.lang.misc

    On 14.09.2024 11:34, Lawrence D'Oliveiro wrote:
    On Sat, 14 Sep 2024 10:06:12 +0200, Janis Papanagnou wrote:

    On 30.08.2024 04:53, Lawrence D'Oliveiro wrote:

    Emacs makes no such assumption, and can also edit non-text files.

    You have obviously no clue.

    I have actually used it for that. That’s my “clue” to you.

    Yes, I've also edited binary files with Vim. - That's no news.
    So what's the "clue"?

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From candycanearter07@candycanearter07@candycanearter07.nomail.afraid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Sep 26 18:00:09 2024
    From Newsgroup: comp.lang.misc

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 22:48 this Saturday (GMT):
    On Sat, 7 Sep 2024 18:30:03 -0000 (UTC), candycanearter07 wrote:

    Subjectively, I prefer early returns over nested ifs:

    Nested ifs nest, early returns don’t.


    Right, they remove some nesting which makes it easier to read.
    --
    user <candycane> is generated from /dev/urandom
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Thu Sep 26 20:36:11 2024
    From Newsgroup: comp.lang.misc

    On Thu, 26 Sep 2024 18:00:09 -0000 (UTC), candycanearter07 wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 22:48 this Saturday (GMT):

    On Sat, 7 Sep 2024 18:30:03 -0000 (UTC), candycanearter07 wrote:

    Subjectively, I prefer early returns over nested ifs:

    Nested ifs nest, early returns don’t.

    Right, they remove some nesting which makes it easier to read.

    Nestability helps with refactorability.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@dastardlyhq.com to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Fri Sep 27 08:03:43 2024
    From Newsgroup: comp.lang.misc

    On Thu, 26 Sep 2024 20:36:11 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boringly babbled:
    On Thu, 26 Sep 2024 18:00:09 -0000 (UTC), candycanearter07 wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 22:48 this Saturday (GMT):

    On Sat, 7 Sep 2024 18:30:03 -0000 (UTC), candycanearter07 wrote:

    Subjectively, I prefer early returns over nested ifs:

    Nested ifs nest, early returns don’t.

    Right, they remove some nesting which makes it easier to read.

    Nestability helps with refactorability.

    Hell it does. All it helps with is making the code harder to follow.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bozo User@anthk@disroot.org to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 30 20:04:52 2024
    From Newsgroup: comp.lang.misc

    On 2024-09-15, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Sat, 14 Sep 2024 22:25:53 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boringly babbled:
    On Sat, 14 Sep 2024 19:10:06 GMT, Scott Lurndal wrote:

    $ man vim | grep -i binary

    -b Binary mode. A few options will be set that makes it >>> possible to edit a binary or executable file.

    Wow, a special mode just to edit binary files, when Emacs can do it in
    its regular mode.

    The 1980s phoned, they want their editor wars back.

    It just sets a bunch of options to minimize the chance of screwing up
    the file in ways you don’t want. Apart from that, it’s still editing
    it as a text file.

    Any sane person uses a dedicated hex editor to edit binary files, not vim
    or emacs.


    Emacs has the hexl-mode. Emacs isn't just an editor, it's an Elisp platform. --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bozo User@anthk@disroot.org to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 30 20:04:53 2024
    From Newsgroup: comp.lang.misc

    On 2024-08-19, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
    On 2024-08-19 16:59, Muttley@dastardlyhq.com wrote:
    On Mon, 19 Aug 2024 12:39:33 +0200

    Initially an ability to trim the system and sometimes to patch a driver
    was a huge advantage Linux had over Windows NT.

    Linux can also load and unload drivers on the fly unlike Windows which AFAIK >> still requires a reboot each time.

    I was talking about monolithic kernel Linux had in 90's. Plug and play, kernel modules came much later with much bigger machines. I ran Linux on i386 25MHz 4Mb. Try it now.


    You could load and unload drivers since slackware 4 and before,
    even under a 386.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Bozo User@anthk@disroot.org to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 30 20:04:54 2024
    From Newsgroup: comp.lang.misc

    On 2024-08-21, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Wed, 21 Aug 2024 09:26:41 +0200, David Brown wrote:

    And you don't need to know anything about Linux, UNIX or POSIX to
    program in C.

    I think the point has been made on comp.lang.c more than once, that C without POSIX can be a very dull language indeed ...

    The C Programming Language 2nd. Ed is not about POSIX, and you can do
    a lot with C99. Albeit I prefer Elisp and Common Lisp.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 30 22:08:00 2024
    From Newsgroup: comp.lang.misc

    On Mon, 30 Sep 2024 20:04:52 -0000 (UTC), Bozo User wrote:

    Any sane person uses a dedicated hex editor to edit binary files, not
    vim or emacs.

    Emacs has the hexl-mode. Emacs isn't just an editor, it's an Elisp
    platform.

    Hex mode is an option. It’s not required. It so happens the kind of
    editing I was doing worked best the way I did it.

    Emacs offers you the choice, alternative editors don’t.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.unix.shell,comp.unix.programmer,comp.lang.misc on Mon Sep 30 22:10:22 2024
    From Newsgroup: comp.lang.misc

    On Mon, 30 Sep 2024 20:04:54 -0000 (UTC), Bozo User wrote:

    On 2024-08-21, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Wed, 21 Aug 2024 09:26:41 +0200, David Brown wrote:

    And you don't need to know anything about Linux, UNIX or POSIX to
    program in C.

    I think the point has been made on comp.lang.c more than once, that C
    without POSIX can be a very dull language indeed ...

    ... you can do a lot with C99.

    Up to a point. This is the thing: every once in a while, a discussion
    about some supposed C feature will founder on the discovery that it is actually a POSIX feature, not available with standard C on non-POSIX platforms.

    Hang around comp.lang.c for a month or so, and you’ll see what I mean.

    Albeit I prefer Elisp and Common Lisp.

    I use lots of languages, including C and JavaScript. I use Elisp to
    customize Emacs, and Python for lots of other things. I have even dabbled
    with Smalltalk.
    --- Synchronet 3.20a-Linux NewsLink 1.114