• Re: How does Pi get its t

    From Ron Lauzon@1:135/383 to Ahem A Rivet's Shot on Sun Feb 13 13:25:03 2022
    Ahem A Rivet's Shot wrote to The Natural Philosopher <=-

    CP/M did not have a heirachial directory system. The CP/M
    filesystem was single level with user IDs and drives being the only separations, user IDs were not visible and a little strange by modern standards - there were only 15 of them with 0 being everyone.

    CP/M filenames were like A:THING.COM - no slashes in any
    direction.

    Later versions of CP/M did have a hierarchial directory structure. But I need to do some research to see if they added that before or after MS-DOS came out.

    The first version of MS-DOS did NOT support sub-directories.


    ... Kinky: Using A Feather. Sick: Using The Whole Chicken
    ___ MultiMail/Linux v0.52

    --- Mystic BBS/QWK v1.12 A47 2021/12/25 (Windows/32)
    * Origin: Rocket Town BBS (1:135/383)
  • From Ahem A Rivet's Shot@3:770/3 to Ron Lauzon on Sun Feb 13 20:23:02 2022
    On Sun, 13 Feb 2022 13:25:03 +1200
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) wrote:

    Ahem A Rivet's Shot wrote to The Natural Philosopher <=-

    CP/M did not have a heirachial directory system. The CP/M filesystem was single level with user IDs and drives being the only separations, user IDs were not visible and a little strange by
    modern standards - there were only 15 of them with 0 being everyone.

    CP/M filenames were like A:THING.COM - no slashes in any direction.

    Later versions of CP/M did have a hierarchial directory structure. But I need to do some research to see if they added that before or after MS-DOS came out.

    I'd like to see details - the CP/M-86 filesystem on the ACT Sirius
    I used didn't have one.

    The first version of MS-DOS did NOT support sub-directories.

    IIRC they came into MS-DOS along with hard disc support in 2.0.

    Heirarchial filesystems go back a *long* way, there are papers from
    the late 1950s but Multics is generally considered to have had the first
    full blown version.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to All on Sun Feb 13 21:24:41 2022
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message news:20220213202302.63391603e153cdcb66cdc6ba@eircom.net...
    On Sun, 13 Feb 2022 13:25:03 +1200
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) wrote:

    Ahem A Rivet's Shot wrote to The Natural Philosopher <=-

    CP/M did not have a heirachial directory system. The CP/M
    filesystem was single level with user IDs and drives being the only
    separations, user IDs were not visible and a little strange by
    modern standards - there were only 15 of them with 0 being
    everyone.

    CP/M filenames were like A:THING.COM - no slashes in any
    direction.

    Later versions of CP/M did have a hierarchial directory structure. But I
    need to do some research to see if they added that before or after MS-DOS
    came out.

    I'd like to see details - the CP/M-86 filesystem on the ACT Sirius
    I used didn't have one.

    The first version of MS-DOS did NOT support sub-directories.

    IIRC they came into MS-DOS along with hard disc support in 2.0.

    Heirarchial filesystems go back a *long* way, there are papers from
    the late 1950s but Multics is generally considered to have had the first
    full blown version.

    Blimey. Multics. I haven't heard that name for a long time. I had fond
    memories of using it at university in the early 1980s. I started out doing physics before changing after a year to elec eng. But I retained the Multics logon that the physics course had given me, so I used to go to the computer room in the late evening to learn about what the OS offered and what the various plotters and printers were capable of. Why the late evening? Well everyone was allocated a quota of logon time which was (in my case) pretty minimal, but chargeable hours ended at (I think) 9 PM and all logon time
    until the following morning was unlimited. It was amazing how many sad nerds there were waiting in the computer room until the clock (metaphorically)
    struck 9.

    When I started in my first job in 1986, our department had Unix (BSD, I
    think) servers and I remember noticing a lot of similarities with Multics, though I can't remember what those similarities were.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ron Lauzon@1:135/383 to Ahem A Rivet's Shot on Mon Feb 14 08:22:30 2022
    Ahem A Rivet's Shot wrote to Dr. What <=-

    I'd like to see details - the CP/M-86 filesystem on the ACT
    Sirius I used didn't have one.

    I'm trying to see if I can find that information, but I'm coming up empty. Maybe I'm thinking about DRI's offerings much later (like DR DOS).

    IIRC they came into MS-DOS along with hard disc support in
    2.0.

    I ran into that while restoring a Sperry portable PC. I found the original DOS for it and used that for the CF card "hard drive". Setting that up was "interesting" in DOS 2.x to say the least.

    Heirarchial filesystems go back a *long* way, there are papers
    from the late 1950s but Multics is generally considered to have had the first full blown version.

    Oh, ya. Even systems like IBM MVS supported something like that. So the idea wasn't new.

    But if you think about the time frame, it was mostly floppy drive systems. Subdirectories don't become really useful until hard drives are relatively common.

    I'm just imagining what it would be like to use a Kaypro 10 (with the hard drive) without subdirectories and that's certainly a different way of thinking.


    ... How do women get minks? Same way minks get minks
    ___ MultiMail/Linux v0.52

    --- Mystic BBS/QWK v1.12 A47 2021/12/25 (Windows/32)
    * Origin: Rocket Town BBS (1:135/383)
  • From Vincent Coen@2:250/1 to Ron Lauzon on Mon Feb 14 14:45:27 2022
    Hello Ron!

    Monday February 14 2022 08:22, you wrote to Ahem A Rivet's Shot:

    Many of the CPM (and MPM) processes came from Digital PDP systems such as PIP. I suspect that includes much of it but by memory is no longer up to it despite having the CPM manual sitting on my system some where along with possible copies of the s/w.

    I owned a company M.P.I (Microcomputer Products International) that distributed
    these products around the world outside of the USA at least until MSDOS became dominant in the early 80's followed by Windows 3.1 (earlier versions where not sold as where considered too buggy or poor in functionality).
    This was along side many of the software applications that run on it.
    The company was around from 75 to 85.



    Vincent

    --- Mageia Linux v8 X64/Mbse v1.0.7.24/GoldED+/LNX 1.1.5-b20180707
    * Origin: Air Applewood, The Linux Gateway to the UK & Eire (2:250/1)
  • From Dennis Lee Bieber@3:770/3 to All on Mon Feb 14 13:44:47 2022
    On Mon, 14 Feb 2022 08:22:30 +1200,
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) declaimed the following:



    I'm trying to see if I can find that information, but I'm coming up empty. >Maybe I'm thinking about DRI's offerings much later (like DR DOS).


    Extracting from some old books (Microprocessor Operating Systems, vols. I-III; John Zarrella, 1981-1984 Microcomputer Applications)

    iRMX-80: single level, directory sized for 200 files (8"), 136 (5.25") iRMX-86: tree-structured directory, uses "/" as path separator
    MP/OS: tree-structured, no sample pathname shown
    Rx: no actual example -- closest is "volumename.filename" UNIX: tree-structured, "/" separator
    VERSAdos: path names are
    <volume>:<user#>.<catalog>.<filename>.<extension>
    (<user#> separates "private" files by user; I'm guessing
    <catalog> is a layer of directories)
    ZRTS: "multi-level directories", no example path shown
    CP/M: single level; max drive 8M (larger drives are split
    into "logical drives")
    CP/M-86: same
    IDRIS: see UNIX
    I/OS: CP/M compatible
    MP/AOS: see MP/OS
    Multiuser OASIS: apparently single-level directory
    OASIS-16: "two-level directory", second level appears to be
    "library" structure... appears to use "." as separator ZEUS: (Zilog Enhanced UNIX System) see UNIX
    Concurrent CP/M: <drive:>8.3<;password>
    16 logical directories identified by user number, but
    physically just a single directory
    MS-DOS: tree-structured directory, uses "\" for path separator
    MSP: single-level
    PICK: very weird four-level scheme
    SYSTEM defines users and disk location
    Master Dictionary: defines files (and verbs)
    per user
    Dictionary: defines fields in data files
    Data
    p-System: standard file system - single level directory (with
    option for second /duplicate/ directory -- to allow
    recovery of "deleted" files); as I recall, the system only
    allows one open /output/ file per drive, as files are
    contiguous, and opening for output claims the
    largest contiguous free space (requires periodic
    packing of files)
    advanced file system -- for large devices, uses
    UNIX-like path
    RM/COS: tree-structured directory, users "." for path separator
    SuperDOS: No actual example path;
    <drive> <usergroup#> <filename>
    files are contiguous and max size must be
    declared when created
    TurboDOS: CP/M compatible

    -=-=-

    From personal experience:

    LS-DOS/TRS-DOS6:
    single level directory; path names
    8/3<.password>:<drv#>
    would scan multiple drives to find file, and for
    output would skip write-protected drives to find
    first writable media (made it easy to use a
    write-protected system drive with writable data
    drive)

    AmigaOS: tree-structured directory; "/" path separator
    <dvl:>name/name/...
    dvl => device name: df0 floppy-0
    dh0 harddrive-0
    hd0 harddrive-0
    (depending on driver)
    volume name: whatever
    logical name: whatever
    (logical names created via command
    ASSIGN lname: pathname
    NOT symlink or environment variable,
    closer to VMS logical names)



    But if you think about the time frame, it was mostly floppy drive systems. >Subdirectories don't become really useful until hard drives are relatively >common.

    I'm just imagining what it would be like to use a Kaypro 10 (with the hard >drive) without subdirectories and that's certainly a different way of thinking.


    Well -- it wouldn't be with today's applications <G>

    How much stuff could you fit on a 5-10 MB hard-drive... Granted, back then, the entire OS and support would fit on a 360kB (or less) floppy.


    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ron Lauzon@1:135/383 to Dennis Lee Bieber on Tue Feb 15 08:49:07 2022
    Dennis Lee Bieber wrote to All <=-

    CP/M: single level; max drive 8M (larger drives are split
    into "logical drives")

    CP/M must not have suffered from the MS-DOS limitation of 255 files in the
    root direcory. Or did it? And that's why they had to split larger drives.

    LS-DOS/TRS-DOS6:
    single level directory; path names
    8/3<.password>:<drv#>
    would scan multiple drives to find file, and
    for
    output would skip write-protected drives to
    find
    first writable media (made it easy to use a
    write-protected system drive with writable data
    drive)

    I noticed that with my TRS-80 Model 4P with FreHD. It didn't take me long to clone some of the hard drive images to make them for specific tasks (i.e. Deskmate, Games, FORTRAN, etc.) just to manage the files.

    How much stuff could you fit on a 5-10 MB hard-drive...
    Granted, back then, the entire OS and support would fit on a 360kB (or less) floppy.

    I remember moving from my floppy based PC to one with a 30 MB hard drive! It took me only a couple of hours to fill up the hard drive from floppies. Then I realized that I needed to start managing my data and decide what needed to be on the primary storage (hard drive) and secondary storage (floppies).


    ... Why get even, when you can get odd?
    ___ MultiMail/Linux v0.52

    --- Mystic BBS/QWK v1.12 A47 2021/12/25 (Windows/32)
    * Origin: Rocket Town BBS (1:135/383)
  • From Ahem A Rivet's Shot@3:770/3 to Ron Lauzon on Tue Feb 15 15:58:46 2022
    On Tue, 15 Feb 2022 08:49:07 +1200
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) wrote:

    Dennis Lee Bieber wrote to All <=-

    CP/M: single level; max drive 8M (larger drives are
    split into "logical drives")

    CP/M must not have suffered from the MS-DOS limitation of 255 files in the root direcory. Or did it? And that's why they had to split larger
    drives.

    The CP/M filesystem could only handle eight megabytes per drive. A
    CP/M directory entry is 32 bytes (files over 16K would use multiple
    directory entries - proper name extents - which cuts down the count). Most floppy formats used one track for the directory giving 64 entries in a 2K
    track - which was plenty for an 80K or even 160K floppy. I don't think
    there was any limit except that imposed by how much of the disc was
    allocated to directory entries which was an implemntors choice.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Dennis Lee Bieber@3:770/3 to All on Tue Feb 15 13:20:49 2022
    On Tue, 15 Feb 2022 08:49:07 +1200,
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) declaimed the following:

    Dennis Lee Bieber wrote to All <=-

    CP/M: single level; max drive 8M (larger drives are split
    into "logical drives")

    CP/M must not have suffered from the MS-DOS limitation of 255 files in the >root direcory. Or did it? And that's why they had to split larger drives.

    "A drive may contain up to 64k separate allocation blocks"; and the driver can be defined to use block sizes from 1kB to 16kB.

    Even though I/O was based upon 128byte sectors, and file length is only known by the number of blocks allocated in the directory (text files need
    to be scanned to find the <EOF> marker).

    Book doesn't mention any limit on directory entries (large /files/ toggle from the directory entry have block pointers to having "extent"
    pointers (to additional directory entries), with the extents having the
    actual block pointers.

    No bit-map of block allocations, per se; each drive has to have the directory scanned to build up a table (in RAM) of which blocks are used/available.



    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Lew Pitcher@3:770/3 to Dennis Lee Bieber on Tue Feb 15 18:56:12 2022
    On Tue, 15 Feb 2022 13:20:49 -0500, Dennis Lee Bieber wrote:

    On Tue, 15 Feb 2022 08:49:07 +1200, nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) declaimed the following:

    Dennis Lee Bieber wrote to All <=-

    CP/M: single level; max drive 8M (larger drives are
    split DLB>
    into "logical drives")

    CP/M must not have suffered from the MS-DOS limitation of 255 files in
    the root direcory. Or did it? And that's why they had to split larger >>drives.

    "A drive may contain up to 64k separate allocation blocks"; and
    the
    driver can be defined to use block sizes from 1kB to 16kB.

    Even though I/O was based upon 128byte sectors, and file length
    is only
    known by the number of blocks allocated in the directory (text files
    need to be scanned to find the <EOF> marker).

    Book doesn't mention any limit on directory entries (large /files/ toggle from the directory entry have block pointers to having "extent" pointers (to additional directory entries), with the extents having the actual block pointers.

    No bit-map of block allocations, per se; each drive has to have
    the
    directory scanned to build up a table (in RAM) of which blocks are used/available.

    The CPM 2.2 Alteration Guide has a bit to say about this.

    The number of directory entries depended on specific hardcoded values in
    the BIOS. The BIOS "Disk Parameter Table" described each attached disk
    drive with various parameters that included a "Disk Parameter Block" for
    each type of drive. The DPB contained a number of values, including # of sectors per track, and the "total number of directory entries which can
    be stored on this drive" (the DRM value), with the AL0 and AL1 allocation bitmaps defining where the (maximum 16) directory data blocks resided
    within the first sectors of the disk.

    A typical disk drive (8" floppy disk, in this case) might have 26 sectors
    per track, with a total of 243 data blocks, and 64 directory entries.
    This, from the example BIOS code (for the Intellec "MDS-800"
    microcomputer development system) included in the Alteration Guide.

    --
    Lew Pitcher
    "In Skills, We Trust"
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jan Panteltje@3:770/3 to Shot on Tue Feb 15 19:38:49 2022
    On a sunny day (Tue, 15 Feb 2022 15:58:46 +0000) it happened Ahem A Rivet's Shot <steveo@eircom.net> wrote in <20220215155846.b7ced525f8e2f5cda59d3c83@eircom.net>:

    On Tue, 15 Feb 2022 08:49:07 +1200
    nospam.Ron.Lauzon@f383.n135.z1.fidonet.org (Ron Lauzon) wrote:

    Dennis Lee Bieber wrote to All <=-

    CP/M: single level; max drive 8M (larger drives are
    split into "logical drives")

    CP/M must not have suffered from the MS-DOS limitation of 255 files in the >> root direcory. Or did it? And that's why they had to split larger
    drives.

    The CP/M filesystem could only handle eight megabytes per drive. A
    CP/M directory entry is 32 bytes (files over 16K would use multiple
    directory entries - proper name extents - which cuts down the count). Most >floppy formats used one track for the directory giving 64 entries in a 2K >track - which was plenty for an 80K or even 160K floppy. I don't think
    there was any limit except that imposed by how much of the disc was
    allocated to directory entries which was an implemntors choice.

    Long time ago I only had a Sinclair ZX80 and then a ZX81.
    So I designed a floppy drive for it, an EPROM programmer, a ramdisk,
    and wanted to play with some CP/M software.
    So I wrote a CP/M clone in the holidays in Z80 asm running on the ZX81 system. Then I designed a CPU card with a Z80, serial output more stuff, modem...

    http://panteltje.com/panteltje/z80/system14/index.html
    http://panteltje.com/panteltje/z80/system14/diagrams/index.html
    http://panteltje.com/panteltje/z80/index.html

    Had Software toolworks C80 C compiler running on it,
    and lots of fun stuff I wrote.
    Only supported the Kaypro2 disk format.
    In those days before the internet we had 'Viditel' here in the Netherlands, sort of a
    file exchange system over the phone, news etc.

    In the later days part of my job was designing PCI cards for in the IBM PC (we worked closely with IBM)
    but I used my home build CP/M system for many years,
    I added an IBM keyboard and driver too :-)

    Its easy!
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to Jan Panteltje on Tue Feb 15 20:45:15 2022
    On Tue, 15 Feb 2022 19:38:49 GMT
    Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:

    So I wrote a CP/M clone in the holidays in Z80 asm running on the ZX81 system.

    Did you ever attempt to get WordStar running ? It gave us some
    trouble at Torch because it was using some undocumented bits (literally
    IIRC) in the directory entry and the reason CPN existed was because I felt quite ill when I saw the extent mechanism and decided it wasn't much harder
    to re-implement and make a decent filesystem than it was to port to the
    hybrid 6502/Z80 environment we had - nobody argued!

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jan Panteltje@3:770/3 to Shot on Wed Feb 16 07:55:44 2022
    On a sunny day (Tue, 15 Feb 2022 20:45:15 +0000) it happened Ahem A Rivet's Shot <steveo@eircom.net> wrote in <20220215204515.3a8050e625e5f323968ec305@eircom.net>:

    On Tue, 15 Feb 2022 19:38:49 GMT
    Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:

    So I wrote a CP/M clone in the holidays in Z80 asm running on the ZX81
    system.

    Did you ever attempt to get WordStar running ?


    No, I mainly used it to write C code and some programs from what was it called ? "The CP/M user club' or something.
    The C compiler was great and I learned programming in C that way.
    At work I did a lot of asm programming for various micros like 8051 etc
    and that code was too much for the programming department that did mainly 8086 asm...
    So one day boss decided we should all learn C and program in C,
    we actually got a one hour lessen in C .. I was at an advantage :-)



    It gave us some
    trouble at Torch because it was using some undocumented bits (literally
    IIRC) in the directory entry and the reason CPN existed was because I felt >quite ill when I saw the extent mechanism and decided it wasn't much harder >to re-implement and make a decent filesystem than it was to port to the >hybrid 6502/Z80 environment we had - nobody argued!

    Later I had a go at writing a multitasking OS for the Z80, it worked
    but memory limitations were too severe for practical use.

    Then I finally bought a real IBM PC win 3.1 and trumpet winsock for the internet.

    In 1998 I got a Linux CD with some magazine and installed SLS Linux on that PC. Have not been back, free C compiler gcc!
    What I missed was Free Agent in Linux, so I wrote NewsFleX:
    http://panteltje.com/panteltje/newsflex/index.html
    about 1999 or so...

    And now all runs on Raspberries here, last time my PC was on was to adjust my satellite dish and do
    something with QO100 (ham satellite), not a very active ham here,
    Once something works I move to the next, 'the experience is the reward' as somebody has as sig
    in sci.electronics.design.
    So now I am playing with that pimoroni infrared FLIR camera module and some other stuff.

    What helped me a lot in the early days was
    https://www.goodreads.com/book/show/3603797-8080-z80-assembly-language
    it also had all the Z80 secret asm statements,
    Also had The C Programming Language by Ritchie & Kernighan, is a free download these days (google).

    ...

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Jan Panteltje on Wed Feb 16 10:21:34 2022
    On Wed, 16 Feb 2022 07:55:44 +0000, Jan Panteltje wrote:

    Also had The C Programming Language by Ritchie & Kernighan, is a free download these days (google).

    Yes, that, or (better choice these days) the second edition which covers
    ANSI C.

    Another book which I think is helpful for almost any new programmer is
    "The Practice of Programming" by Kernighan and Pike. This shows how to
    write well-structured code with meaningful names that's easy to read,
    modify and debug. The book is really intended for new C programmers, but
    what it has to say about choosing function and variable names as well as designing (and commenting) programs so they are easy to maintain and is relevant to almost any programming language except the real oddballs like
    FORTH and APL.

    This book, and the ideas in it, should work for almost any language
    though its written round C. It deals with topics that, IME, most books
    and courses that claim to teach a programming language should cover but
    don't and it shows, especially in some of the COBOL systems I've had to maintain in the past. The worst I think I ever saw was updated by one Ken Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From A. Dumas@3:770/3 to Martin Gregorie on Wed Feb 16 12:36:59 2022
    On 16-02-2022 11:21, Martin Gregorie wrote:
    The worst I think I ever saw was updated by one Ken
    Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Holy shit. Legend! (And an asshole.)
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to A. Dumas on Wed Feb 16 12:50:28 2022
    On Wed, 16 Feb 2022 12:36:59 +0100, A. Dumas wrote:

    On 16-02-2022 11:21, Martin Gregorie wrote:
    The worst I think I ever saw was updated by one Ken Eagle, who called
    any numeric variables he added KENn and any strings EAGLEn and clearly
    didn't give a shit about anybody else who might have to maintain the
    code in future, hence you'd see lines in code he'd touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Holy shit. Legend! (And an asshole.)

    That was back in the '70s, when there were some real chancers among some
    of the freelancers.

    Another pair who stood out (this was on an (unnamed) large Civil Service project in Bath:

    - One of them was well-known among the locally-based freelancers because
    none of them could remeber this gent actually finishing a project.
    His speciality was to put in lots of overtime and then quit abruptly
    just before system testing started. His 'completed' programs usually
    weren't.

    - Another well-known member of that tribe was considered unlikely to know
    that, in a COBOL program, code in a paragraph defaults to falling
    through into the following one unless there's a explicit GO TO,
    STOP RUN or the paragraph is that last one in a PERFORMED SECTION or
    set of PERFORMED paragraphs.

    We knew this because his programs always contained several sequences
    that looked like this..... i.e. were sprinkled with line pairs like
    lines 6 to 8 in the following:

    LOOP-START.
    READ IN-FILE
    AT END GO TO LOOP_EXIT.

    NOTE a set of moves, additions, PERFORMs etc
    GO TO LOOP-END.

    LOOP-END.
    NOTE more code that completes the in-loop processing.
    GO TO LOOP-START.

    LOOP_EXIT.
    ...

    but at least his code usually worked....
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to A. Dumas on Wed Feb 16 13:59:56 2022
    On 16/02/2022 11:36, A. Dumas wrote:
    On 16-02-2022 11:21, Martin Gregorie wrote:
    The worst I think I ever saw was updated by one Ken
    Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Holy shit. Legend! (And an asshole.)

    He had probably been unfairly castigated for buggering up someone's code
    in the past, so now simply ensured his changes were identifiable.

    I generally find the better the coder the less obfuscated the code.,

    REGEXPS are for wannabe geniuses who have learnt regexp but still cant
    write clean workmanlike code.

    Nowadays with optimising compilers there is no excuse for
    a=(b? c:d);

    when
    if(b)
    a=c;
    else a=d;

    will probably compile to the same thing.


    --
    “It is dangerous to be right in matters on which the established
    authorities are wrong.”

    ― Voltaire, The Age of Louis XIV
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jan Panteltje@3:770/3 to Gregorie on Wed Feb 16 13:40:01 2022
    On a sunny day (Wed, 16 Feb 2022 10:21:34 -0000 (UTC)) it happened Martin Gregorie <martin@mydomain.invalid> wrote in <suij7d$raa$1@dont-email.me>:

    On Wed, 16 Feb 2022 07:55:44 +0000, Jan Panteltje wrote:

    Also had The C Programming Language by Ritchie & Kernighan, is a free
    download these days (google).

    Yes, that, or (better choice these days) the second edition which covers
    ANSI C.

    Another book which I think is helpful for almost any new programmer is
    "The Practice of Programming" by Kernighan and Pike. This shows how to
    write well-structured code with meaningful names that's easy to read,
    modify and debug. The book is really intended for new C programmers, but
    what it has to say about choosing function and variable names as well as >designing (and commenting) programs so they are easy to maintain and is >relevant to almost any programming language except the real oddballs like >FORTH and APL.

    This book, and the ideas in it, should work for almost any language
    though its written round C. It deals with topics that, IME, most books
    and courses that claim to teach a programming language should cover but
    don't and it shows, especially in some of the COBOL systems I've had to >maintain in the past. The worst I think I ever saw was updated by one Ken >Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Yes, it is absolutely essential to write clear code.
    For example now with my xflir code I use pieces of the Melexis library source for their camera in my code.
    They use printf("whatever")

    I make a big distinction between fprintf(stderr and fprintf(stdout.
    One of the reasons is so that I can pipe the output from stdout of my programs via other cool programs
    to get much more done,
    For example this runs now in a test:
    xflir -f 20.0 -u 34.0 -j 2 -k 10 -l 27 -m 31 -r -p -w 1 -x -c 4 -y | ffmpeg -i - -vcodec libx264 -y test2.avi

    I added yuv output, that format can be read by mplayer and ffmpeg, so makes it easy to make a compressed h264 avi uing ffmpeg.

    The other thing is that every function I write is like this:
    char *get_time_as_string(int short_format_flag, int ut_flag)
    {
    time_t now;
    char temp[1024];
    struct tm *universal_time, *local_time;
    char *ptr;

    if(verbose)
    {
    fprintf(stderr,\
    "get_time_as_string(): arg short_format_flag=%d ut_flag=%d\n",\
    short_format_flag, ut_flag);
    }
    ...code...


    if there is a problem say a crash I can activate verbose level on the command line
    and see exactly where and with what parameters things went wrong (as it usually exits there).
    Or just comment out 'verbose' in the interesting part of code and see what happens.

    And the third thing is that all my functions return 0 for error, so I can write if(! this_big_function)
    {
    fprintf(stderr, "this_big_function failed, aborting.\n");

    }

    Nice if the function is a char* and returns a 0 pointer
    and the 'not' statement is logical in the thinking process.

    And fourth there is indentation

    for(x = 0; x < 10; x++)
    {
    do something
    }

    Note where the brackets are


    There is more of course, over the years you build up nice C collection of routines that
    have proven themselves to be reliable.
    So I usually do not need to link in big libraries.
    This only uses libc and libmath and the standard Xlibraries
    LIBRARY = -lXaw -lXext -lX11 -lXt -lm
    result: small file size, < 41 kB
    40820 Feb 16 14:23 xflir

    And then there is parameters, That FLIR camera has low resolution 24 x 32.
    So the Melexis code uses many times 24 and 32 but also 768 (is 24 x 32) and other funny numbers.
    Replaced all that by defines so I can easily upgrade to a higher resolution camera...
    This all works through to the size of the buffers, xbuffer etc.

    There is more, better stop here....
    ;-)
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to The Natural Philosopher on Wed Feb 16 14:36:03 2022
    "The Natural Philosopher" <tnp@invalid.invalid> wrote in message news:suj00t$t99$1@dont-email.me...
    I generally find the better the coder the less obfuscated the code.,

    I'd say the opposite. Unless something has to be super-efficient I tend to
    take small nibbles at a problem because it is easy to understand the code
    and (more importantly) easier to understand what I was intending to achieve. Clever people try to show how clever they are by writing very obfuscated
    code which does in one line what takes several lines of more understandable
    and maintainable code. Having said that, is the cleverer, more efficient
    coder "better" if his code is harder to maintain?

    I worked with one guy who had a quad-core brain at a time when the rest of
    us had single-core brains. And his C code was exceptionally efficient
    because he'd studied the source code of the compiler, but no-one else could understand what the F it was supposed to do. It was recommended that you
    never ask him a question, not because he'd tell you to F-off, but because he would answer your question in far more detail than you wanted, and then he'd
    go on to answer all the related questions that you might have asked him
    next.

    He was a walking-lookup table of telephone STD codes and dashboard
    instruments in cars ("ah yes, 01423 is Harrogate, and if the subscriber's number starts with 61 it's in Woodlands whereas if it starts with 62 it's in Oatlands" or "ah yes, that speedometer was used in a Ford Cortina between
    1962 and 1963, a Ford Corsair between 1963 and 1965 and a very similar one
    that was calibrated up to 100 rather than 90 mph was used in the Zephyr
    GT"). He apparently discovered a very obscure bug in a device driver (*)
    that was supplied with a third-party network card, fixed it and offered the
    fix (with his manager's approval) back to the card vendor so everyone else would benefit from it.

    (*) Looking only at the EXE file, with no source code.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to Jan Panteltje on Wed Feb 16 14:45:34 2022
    "Jan Panteltje" <pNaonStpealmtje@yahoo.com> wrote in message news:suiusa$a18$1@dont-email.me...

    And fourth there is indentation

    for(x = 0; x < 10; x++)
    {
    do something
    }

    Note where the brackets are

    Kernighan and Ritchie have got a *lot* to answer for in promoting the indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    or

    for(x = 0; x < 10; x++) {
    do something
    }

    I like my opening and closing braces to line up so I can count if I've got
    more opening than closing etc:

    if (a==b)
    {
    do something
    }
    else
    {
    do something
    }


    I've seen if statements written all on one line

    if (a==b) a++; else { b++; c++ }

    Which is legal - but tedious to try to read.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to Martin Gregorie on Wed Feb 16 14:16:56 2022
    "Martin Gregorie" <martin@mydomain.invalid> wrote in message news:suiruk$d44$1@dont-email.me...
    On Wed, 16 Feb 2022 12:36:59 +0100, A. Dumas wrote:

    On 16-02-2022 11:21, Martin Gregorie wrote:
    The worst I think I ever saw was updated by one Ken Eagle, who called
    any numeric variables he added KENn and any strings EAGLEn and clearly
    didn't give a shit about anybody else who might have to maintain the
    code in future, hence you'd see lines in code he'd touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Holy shit. Legend! (And an asshole.)

    That was back in the '70s, when there were some real chancers among some
    of the freelancers.

    Another pair who stood out (this was on an (unnamed) large Civil Service project in Bath:

    - One of them was well-known among the locally-based freelancers because
    none of them could remeber this gent actually finishing a project.
    His speciality was to put in lots of overtime and then quit abruptly
    just before system testing started. His 'completed' programs usually
    weren't.

    - Another well-known member of that tribe was considered unlikely to know
    that, in a COBOL program, code in a paragraph defaults to falling
    through into the following one unless there's a explicit GO TO,
    STOP RUN or the paragraph is that last one in a PERFORMED SECTION or
    set of PERFORMED paragraphs.

    We knew this because his programs always contained several sequences
    that looked like this..... i.e. were sprinkled with line pairs like
    lines 6 to 8 in the following:

    LOOP-START.
    READ IN-FILE
    AT END GO TO LOOP_EXIT.

    NOTE a set of moves, additions, PERFORMs etc
    GO TO LOOP-END.

    LOOP-END.
    NOTE more code that completes the in-loop processing.
    GO TO LOOP-START.

    LOOP_EXIT.
    ...

    but at least his code usually worked....


    Then you get onto C...

    The trouble with C is that it allows "side-effects" which can cause some
    very obfuscated code which is perfectly legal - and is a nightmare to understand.

    I saw some code of the form

    array1[i++] = b;
    array2[--i] =c;
    array3[i++] = d;

    What's wrong with the much simpler

    array1[i] = b;
    array2[i] = c;
    array3[i++] = d;

    or

    array1[i] = b;
    array2[i] = c;
    array3[i] = d;
    i += 1;

    What's the point of incrementing i after use for array1 if you are going to decrement it again before use to its original value for array2?



    If I have to do anything "clever" to give extra efficiency, I tend to add a comment to say "this is a more efficient equivalent of <less efficient but
    more understandable code>".


    As a matter of interest, are i++, i +=1 and i = i + 1 equally efficient for most compilers?
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to All on Wed Feb 16 15:03:46 2022
    On 16/02/2022 14:16, NY wrote:
    As a matter of interest, are i++, i +=1 and i = i + 1 equally efficient
    for most compilers?

    yes.

    Modern compilers are better at writing assembler than I am.

    If [i] is a register sized integer they will all result in INC AX or
    whatever.

    It is also a toss up whether an ADD command will be used to add say 2
    rather than a pair of INCs.


    All the shorthand that C is capable of and was very useful in the days
    of impossible to use teletypes, and zero disk space is now equivalent to
    all the long winded but easy to understand analogs.


    --
    It is the folly of too many to mistake the echo of a London coffee-house
    for the voice of the kingdom.

    Jonathan Swift
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to sometimes on Wed Feb 16 15:11:50 2022
    On 16/02/2022 14:36, NY wrote:
    "The Natural Philosopher" <tnp@invalid.invalid> wrote in message news:suj00t$t99$1@dont-email.me...
    I generally find the better the coder the less obfuscated the code.,

    I'd say the opposite. Unless something has to be super-efficient I tend
    to take small nibbles at a problem because it is easy to understand the
    code and (more importantly) easier to understand what I was intending to achieve. Clever people try to show how clever they are by writing very obfuscated code which does in one line what takes several lines of more understandable and maintainable code. Having said that, is the cleverer,
    more efficient coder "better" if his code is harder to maintain?

    No. And cleverness is a quality sought by not so clever people, and in
    the possession of people who don't need to show it off.



    I worked with one guy who had a quad-core brain at a time when the rest
    of us had single-core brains. And his C code was exceptionally efficient because he'd studied the source code of the compiler, but no-one else
    could understand what the F it was supposed to do. It was recommended
    that you never ask him a question, not because he'd tell you to F-off,
    but because he would answer your question in far more detail than you
    wanted, and then he'd go on to answer all the related questions that you might have asked him next.

    That is before the days of optimizing compilers then. I used to
    sometimes write like that with rubbish compilers



    He was a walking-lookup table of telephone STD codes and dashboard instruments in cars ("ah yes, 01423 is Harrogate, and if the
    subscriber's number starts with 61 it's in Woodlands whereas if it
    starts with 62 it's in Oatlands" or "ah yes, that speedometer was used
    in a Ford Cortina between 1962 and 1963, a Ford Corsair between 1963 and
    1965 and a very similar one that was calibrated up to 100 rather than 90
    mph was used in the Zephyr GT"). He apparently discovered a very obscure
    bug in a device driver (*) that was supplied with a third-party network
    card, fixed it and offered the fix (with his manager's approval) back to
    the card vendor so everyone else would benefit from it.

    (*) Looking only at the EXE file, with no source code.

    We have all done that. In fact I and a more hardware guy offered a fix
    to a hardware company who had supplied a peripheral card whose timings
    were clearly well out of spec. As evinced by the bug that showed up when
    using DMA to transfer data off a floppy disk.

    Their response? 'No one else has reported any issues'

    Sigh. Some people like to write good workmanlike code, other people have
    small penises and yet more just want to make money without doing any
    hard work.

    I remember a woman who had worked on a certain hardware store that could
    tell you what thread any screw you showed her was instantly. "1/4"
    Whitworth" "3/16" UNC" and so on.

    --
    "A point of view can be a dangerous luxury when substituted for insight
    and understanding".

    Marshall McLuhan
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to All on Wed Feb 16 15:12:57 2022
    On 16/02/2022 14:45, NY wrote:
    I like my opening and closing braces to line up so I can count if I've
    got more opening than closing etc:

    if (a==b)
       {
       do something
       }
    else
       {
       do something
       }

    My code always looks like that.

    I cant read the other forms so fast

    --
    Any fool can believe in principles - and most of them do!
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to All on Wed Feb 16 15:15:15 2022
    On 16/02/2022 14:45, NY wrote:
    I've seen if statements written all on one line

    if (a==b) a++; else { b++; c++ }

    Which is legal - but tedious to try to read.

    x=(a==b)? a++: b++ + c++;

    :-)

    Then throw x away.


    --
    Any fool can believe in principles - and most of them do!
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Tony van der Hoff@3:770/3 to Martin Gregorie on Wed Feb 16 15:59:29 2022
    On 16/02/2022 15:40, Martin Gregorie wrote:
    On Wed, 16 Feb 2022 14:45:34 +0000, NY wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the
    indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    Agreed - I hate reading code with opening and closing 'brackets' which
    are not on the same level, but I put the brackets on the same level as
    the introductory statement, e.g.

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    }
    else
    {
    do_something_else();
    }
    }



    Yes; that's the way to do it!

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to The Natural Philosopher on Wed Feb 16 15:49:15 2022
    On Wed, 16 Feb 2022 13:59:56 +0000
    The Natural Philosopher <tnp@invalid.invalid> wrote:

    I generally find the better the coder the less obfuscated the code.,

    Yep.

    REGEXPS are for wannabe geniuses who have learnt regexp but still cant
    write clean workmanlike code.

    There are things best done with regular expressions, just not as
    many as they get used for.

    Nowadays with optimising compilers there is no excuse for
    a=(b? c:d);

    when
    if(b)
    a=c;
    else a=d;

    will probably compile to the same thing.

    It *might* make the code more readable, especially if that is an established house style. The general point holds though - source code is
    for people to read and should be clear to them.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to All on Wed Feb 16 15:40:55 2022
    On Wed, 16 Feb 2022 14:45:34 +0000, NY wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    Agreed - I hate reading code with opening and closing 'brackets' which
    are not on the same level, but I put the brackets on the same level as
    the introductory statement, e.g.

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    }
    else
    {
    do_something_else();
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to The Natural Philosopher on Wed Feb 16 16:20:38 2022
    On Wed, 16 Feb 2022 15:15:15 +0000
    The Natural Philosopher <tnp@invalid.invalid> wrote:

    x=(a==b)? a++: b++ + c++;

    :-)

    Then throw x away.

    a nice example of how *not* to use ternary expressions, not as bad
    as recursing in multiple ways in the expression though.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to me@privacy.invalid on Wed Feb 16 16:18:21 2022
    On Wed, 16 Feb 2022 14:45:34 -0000
    "NY" <me@privacy.invalid> wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    If you had to work on a single 24 line, 80 column screen you would
    want to conserve lines too - those three lines saved are an eighth of the available screen space.

    Like the often criticised use of null terminated strings the choice made sense in context.

    I like my opening and closing braces to line up so I can count if I've
    got more opening than closing etc:

    if (a==b)
    {
    do something
    }
    else
    {
    do something
    }

    I do too - but less indented than you - so they align with the enclosing block rather than the enclosed.


    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From scott@alfter.diespammersdie.us@3:770/3 to Martin Gregorie on Wed Feb 16 16:39:39 2022
    Martin Gregorie <martin@mydomain.invalid> wrote:
    On Wed, 16 Feb 2022 14:45:34 +0000, NY wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the
    indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    Agreed - I hate reading code with opening and closing 'brackets' which
    are not on the same level, but I put the brackets on the same level as
    the introductory statement, e.g.

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    }
    else
    {
    do_something_else();
    }
    }

    This, except I'm likely to leave them out if they only enclose a single statement. I'd use this:

    void function(int arg)
    {
    if (arg)
    do_this();
    else
    do_something_else();
    }

    If a piece of code expands beyond one statement, then I'll add the brackets:

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    and_that();
    }
    else
    do_something_else();
    }


    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet? --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to Ahem A Rivet's Shot on Wed Feb 16 18:09:49 2022
    On 16/02/2022 16:18, Ahem A Rivet's Shot wrote:
    On Wed, 16 Feb 2022 14:45:34 -0000
    "NY" <me@privacy.invalid> wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the
    indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    If you had to work on a single 24 line, 80 column screen you would
    want to conserve lines too - those three lines saved are an eighth of the available screen space.

    you were lucky, Most of us had a one line teleprinter





    --
    “Progress is precisely that which rules and regulations did not foresee,”

    – Ludwig von Mises
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to Ahem A Rivet's Shot on Wed Feb 16 18:08:44 2022
    On 16/02/2022 16:20, Ahem A Rivet's Shot wrote:
    On Wed, 16 Feb 2022 15:15:15 +0000
    The Natural Philosopher <tnp@invalid.invalid> wrote:

    x=(a==b)? a++: b++ + c++;

    :-)

    Then throw x away.

    a nice example of how *not* to use ternary expressions,

    :-)

    not as bad
    as recursing in multiple ways in the expression though.


    Ooh, you are naughty! give us an example.


    --
    “Progress is precisely that which rules and regulations did not foresee,”

    – Ludwig von Mises
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Charlie Gibbs@3:770/3 to scott@alfter.diespammersdie.us on Wed Feb 16 18:23:19 2022
    On 2022-02-16, scott@alfter.diespammersdie.us
    <scott@alfter.diespammersdie.us> wrote:

    Martin Gregorie <martin@mydomain.invalid> wrote:

    On Wed, 16 Feb 2022 14:45:34 +0000, NY wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting
    the indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    Agreed - I hate reading code with opening and closing 'brackets'
    which are not on the same level,

    That depends on how you define "level". Syntactically, they _are_ on
    the same level; they're just in different columns. The above example
    keeps the line count down. I prefer concise code as long as readability
    isn't compromised, and I don't have trouble with the opening brace being
    off to the right. Neither does vi - put the cursor on one brace and
    hit "%", and it'll find the corresponding one wherever it is.

    but I put the brackets on the same level as
    the introductory statement, e.g.

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    }
    else
    {
    do_something_else();
    }
    }

    Agreed. I think of the braces as a container, so they belong on
    the outer level, as opposed to the contents of the container.

    This, except I'm likely to leave them out if they only enclose a single statement. I'd use this:

    void function(int arg)
    {
    if (arg)
    do_this();
    else
    do_something_else();
    }

    If a piece of code expands beyond one statement, then I'll add the brackets:

    void function(int arg)
    {
    if (arg)
    {
    do_this();
    and_that();
    }
    else
    do_something_else();
    }

    I do this except that I don't allow code to jump up more than
    one level at a time, as the last two lines of your examples do.
    I insist on seeing something at each level on the way out.
    This rule requires a closing brace after do_something_else().

    Note that the rule is satisfied in this case:

    void function(int arg)
    {
    if(arg)
    do_this();
    else
    do_someting_else();
    do_common_stuff();
    }

    I'd write your first example as:

    void function(int arg)
    {
    if(arg) {
    do_this();
    } else {
    do_something_else();
    }
    }

    The braces around do_something_else() are required by my rule.
    The ones around do_this() aren't strictly necessary, but since
    I've put braces around do_something_else() I put them in for
    consistency. (I'm a big fan of consistency.)

    I don't mind a few extra characters if they reduce ambiguity.
    That's why I write things like:

    if((x == 1) || (x == 3)) ...

    A few extra parentheses are quicker to write (or read) than
    trying to remember subtleties of operator precedence.

    --
    /~\ Charlie Gibbs | Microsoft is a dictatorship.
    \ / <cgibbs@kltpzyxm.invalid> | Apple is a cult.
    X I'm really at ac.dekanfrus | Linux is anarchy.
    / \ if you read it the right way. | Pick your poison.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to The Natural Philosopher on Wed Feb 16 19:05:49 2022
    On Wed, 16 Feb 2022 18:09:49 +0000
    The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 16/02/2022 16:18, Ahem A Rivet's Shot wrote:
    On Wed, 16 Feb 2022 14:45:34 -0000
    "NY" <me@privacy.invalid> wrote:

    Kernighan and Ritchie have got a *lot* to answer for in promoting the
    indentation

    if (a==b) {
    do something
    } else {
    do something
    }

    If you had to work on a single 24 line, 80 column screen you
    would want to conserve lines too - those three lines saved are an
    eighth of the available screen space.

    you were lucky, Most of us had a one line teleprinter

    I didn't mean me, I meant Kernighan, Ritchie, Pike et al - a hand
    card punch is the least convenient editing device I have used.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Adam Funk@3:770/3 to Martin Gregorie on Wed Feb 16 19:24:49 2022
    On 2022-02-16, Martin Gregorie wrote:

    On Wed, 16 Feb 2022 07:55:44 +0000, Jan Panteltje wrote:

    Also had The C Programming Language by Ritchie & Kernighan, is a free
    download these days (google).

    Yes, that, or (better choice these days) the second edition which covers
    ANSI C.

    Another book which I think is helpful for almost any new programmer is
    "The Practice of Programming" by Kernighan and Pike. This shows how to
    write well-structured code with meaningful names that's easy to read,
    modify and debug. The book is really intended for new C programmers, but
    what it has to say about choosing function and variable names as well as designing (and commenting) programs so they are easy to maintain and is relevant to almost any programming language except the real oddballs like FORTH and APL.

    This book, and the ideas in it, should work for almost any language
    though its written round C. It deals with topics that, IME, most books
    and courses that claim to teach a programming language should cover but
    don't and it shows, especially in some of the COBOL systems I've had to maintain in the past. The worst I think I ever saw was updated by one Ken Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Was this partly to make himself indispensable (i.e., no-one else would
    be able to patch his code)?



    --
    A person who won't read has no advantage over one who can't read.
    ---Mark Twain
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to The Natural Philosopher on Wed Feb 16 19:22:11 2022
    "The Natural Philosopher" <tnp@invalid.invalid> wrote in message news:suj4e3$876$3@dont-email.me...
    On 16/02/2022 14:45, NY wrote:
    I've seen if statements written all on one line

    if (a==b) a++; else { b++; c++ }

    Which is legal - but tedious to try to read.

    x=(a==b)? a++: b++ + c++;

    What's that in English?

    if (a==b)
    x = a++;
    else
    x = b++ + c++;



    :-)

    Then throw x away.

    Or throw the coder away ;-)



    The old "if (a==b)" reminds me of one of my last-minute checks I make of any code:

    grep if source.c > if.txt
    grep == if.txt > if-double-equal.txt
    grep = if.txt > if-single-equal.txt
    diff if-double-equal.txt if-single-equal.txt

    The two txt files should be the same, or there should be a small number of differences that can be reviewed on a case-by-case basis.

    I'm looking for the dreaded "if (a=b)" test which is almost never what is intended ;-)



    As regards

    if (a ==b)
    {
    lines
    }
    else
    {
    lines
    }

    versus

    if (a ==b)
    {
    lines
    }
    else
    {
    lines
    }

    I tend to prefer the first because I tend to think of the braces as
    belonging with the code they embrace, but I'd not make a hard and fast rule
    as long as it was done consistently.

    I tend to use two spaces for each level of indentation because it's enough
    for the indentation to be easily visible by eye without the code
    disappearing off into "indentation hell" off the RHS of the screen/window
    with very few levels of nesting.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Ahem A Rivet's Shot on Wed Feb 16 20:13:59 2022
    On Wed, 16 Feb 2022 19:05:49 +0000, Ahem A Rivet's Shot wrote:


    I didn't mean me, I meant Kernighan, Ritchie, Pike et al - a hand
    card punch is the least convenient editing device I have used.

    The old 12 key punches were damn good for fixing single single character mistakes provided your computer used a optical card reader with a
    straight card path. Fortunately this was the case for all ICL 1900 card- readers. We used to do that all the time. Beat the crap out of repunching
    a whole card.

    Not so good on an ICL 2900, however: they had a 4000 cpm optical card
    reader but the card path had a fairly large diameter semicircle in it
    where the card passed the optical sensors on its way to the output card stacker. That turn was tight enough to eject any manually implanted card
    chads from their holes.

    And, of course no good at all if the card reader was old enough to use
    copper brush sensors.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Adam Funk on Wed Feb 16 20:28:18 2022
    On Wed, 16 Feb 2022 19:24:49 +0000, Adam Funk wrote:

    On 2022-02-16, Martin Gregorie wrote:

    On Wed, 16 Feb 2022 07:55:44 +0000, Jan Panteltje wrote:

    Also had The C Programming Language by Ritchie & Kernighan, is a free
    download these days (google).

    Yes, that, or (better choice these days) the second edition which
    covers ANSI C.

    Another book which I think is helpful for almost any new programmer is
    "The Practice of Programming" by Kernighan and Pike. This shows how to
    write well-structured code with meaningful names that's easy to read,
    modify and debug. The book is really intended for new C programmers,
    but what it has to say about choosing function and variable names as
    well as designing (and commenting) programs so they are easy to
    maintain and is relevant to almost any programming language except the
    real oddballs like FORTH and APL.

    This book, and the ideas in it, should work for almost any language
    though its written round C. It deals with topics that, IME, most books
    and courses that claim to teach a programming language should cover but
    don't and it shows, especially in some of the COBOL systems I've had to
    maintain in the past. The worst I think I ever saw was updated by one
    Ken Eagle, who called any numeric variables he added KENn and any
    strings EAGLEn and clearly didn't give a shit about anybody else who
    might have to maintain the code in future, hence you'd see lines in
    code he'd touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    Was this partly to make himself indispensable (i.e., no-one else would
    be able to patch his code)?

    No, because he'd long gone before I had to make changes to code he'd
    previously amended. That programming shop has absolutely no discernable programming standards - every system thy had seemed to have invented its
    own and the analysts, who kept themselves very much to then selves in
    another part of the building never kept amendment documentation: as soon
    as the patched code went live, the fix documentation went in the bin.

    Amazingly, the company still exists....
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to Martin Gregorie on Wed Feb 16 20:41:40 2022
    On Wed, 16 Feb 2022 20:13:59 -0000 (UTC)
    Martin Gregorie <martin@mydomain.invalid> wrote:

    On Wed, 16 Feb 2022 19:05:49 +0000, Ahem A Rivet's Shot wrote:


    I didn't mean me, I meant Kernighan, Ritchie, Pike et al - a
    hand card punch is the least convenient editing device I have used.

    The old 12 key punches were damn good for fixing single single character mistakes provided your computer used a optical card reader with a
    straight card path.

    We used a 1442, sort of like a baby MFCM. I got quite adept with the card saw.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to me@privacy.invalid on Wed Feb 16 20:36:33 2022
    On Wed, 16 Feb 2022 19:22:11 -0000
    "NY" <me@privacy.invalid> wrote:

    I'm looking for the dreaded "if (a=b)" test which is almost never what is intended ;-)

    For tests like if (x==3) writing it as if (3=x) generates an error
    if you miss out the second = like I just did - one legal reversal of
    convention that is useful, unlike using 5[x] insteadof x[5] which just
    confuses people.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From druck@3:770/3 to All on Wed Feb 16 21:16:19 2022
    On 16/02/2022 14:16, NY wrote:
    The trouble with C is that it allows "side-effects" which can cause some
    very obfuscated code which is perfectly legal - and is a nightmare to understand.

    I saw some code of the form

    array1[i++] = b;
    array2[--i] =c;
    array3[i++] = d;

    You could come up with a similar contrived example in just about any
    language.

    ---druck
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From druck@3:770/3 to All on Wed Feb 16 21:26:58 2022
    T24gMTYvMDIvMjAyMiAxNDo0NSwgTlkgd3JvdGU6DQo+IEtlcm5pZ2hhbiBhbmQgUml0Y2hp ZSBoYXZlIGdvdCBhICpsb3QqIHRvIGFuc3dlciBmb3IgaW4gcHJvbW90aW5nIHRoZSANCj4g aW5kZW50YXRpb24NCj4gDQo+IGlmIChhPT1iKSB7DQo+ICDCoMKgIGRvIHNvbWV0aGluZw0K PiB9IGVsc2Ugew0KPiAgwqDCoCBkbyBzb21ldGhpbmcNCj4gfQ0KPiANCj4gb3INCj4gDQo+ IGZvcih4ID0gMDsgeCA8IDEwOyB4KyspIHsNCj4gIMKgwqAgZG8gc29tZXRoaW5nDQo+IH0N Cg0KQWdyZWVkIQ0KDQo+IEkgbGlrZSBteSBvcGVuaW5nIGFuZCBjbG9zaW5nIGJyYWNlcyB0 byBsaW5lIHVwIHNvIEkgY2FuIGNvdW50IGlmIEkndmUgDQo+IGdvdCBtb3JlIG9wZW5pbmcg dGhhbiBjbG9zaW5nIGV0YzoNCj4gDQo+IGlmIChhPT1iKQ0KPiAgwqDCoCB7DQo+ICDCoMKg IGRvIHNvbWV0aGluZw0KPiAgwqDCoCB9DQo+IGVsc2UNCj4gIMKgwqAgew0KPiAgwqDCoCBk byBzb21ldGhpbmcNCj4gIMKgwqAgfQ0KDQpIZXJlc3khIFRoZSBvbmUgdHJ1ZSBmb3JtIGlz Oi0NCg0KaWYgKGE9PWIpDQp7DQogICAgIGRvIHNvbWV0aGluZw0KfQ0KZWxzZQ0Kew0KICAg ICBkbyBzb21ldGhpbmcNCn0NCg0KLS0tZHJ1Y2sNCg0K

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From druck@3:770/3 to Martin Gregorie on Wed Feb 16 21:24:15 2022
    On 16/02/2022 10:21, Martin Gregorie wrote:
    The worst I think I ever saw was updated by one Ken
    Eagle, who called any numeric variables he added KENn and any strings
    EAGLEn and clearly didn't give a shit about anybody else who might have
    to maintain the code in future, hence you'd see lines in code he'd
    touched like:

    ADD KEN15 TO KEN5 GIVING KEN9.
    MOVE KEN9 TO EAGLE2.

    I saw a similar technique used to protect commercial software written in
    BBC BASIC from being plagiarised. As it was interpreted BASIC it had to
    be supplied in a form which could be read by both humans and the
    computer, but they had renamed every variable and every procedure to a
    variant of 'ClaresMicroSupplies' with each instance have a different combination of upper and lower case letters. The computer could still
    execute it, but humans just find it impossible to distinguish between
    the variants.

    ---druck

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to All on Wed Feb 16 21:38:06 2022
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message news:20220216203633.269bc9dd86e04f91711d66b4@eircom.net...
    On Wed, 16 Feb 2022 19:22:11 -0000
    "NY" <me@privacy.invalid> wrote:

    I'm looking for the dreaded "if (a=b)" test which is almost never what is
    intended ;-)

    For tests like if (x==3) writing it as if (3=x) generates an error
    if you miss out the second = like I just did - one legal reversal of convention that is useful

    I like it. Looks a bit odd but it's good defensive coding.

    unlike using 5[x] insteadof x[5] which just confuses people.

    The writers of compilers actually allow 5[x] as a synonym for x[5] (where x
    is an array)? WTF!

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to druck on Wed Feb 16 21:53:57 2022
    On Wed, 16 Feb 2022 21:16:19 +0000
    druck <news@druck.org.uk> wrote:

    On 16/02/2022 14:16, NY wrote:
    The trouble with C is that it allows "side-effects" which can cause
    some very obfuscated code which is perfectly legal - and is a nightmare
    to understand.

    I saw some code of the form

    array1[i++] = b;
    array2[--i] =c;
    array3[i++] = d;

    You could come up with a similar contrived example in just about any language.

    j[i] = ++i[j++];

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to me@privacy.invalid on Wed Feb 16 21:57:06 2022
    "NY" <me@privacy.invalid> writes:
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message
    "NY" <me@privacy.invalid> wrote:

    I'm looking for the dreaded "if (a=b)" test which is almost never
    what is intended ;-)

    For tests like if (x==3) writing it as if (3=x) generates an error
    if you miss out the second = like I just did - one legal reversal of
    convention that is useful

    I like it. Looks a bit odd but it's good defensive coding.

    Since the compiler can warn or error for if(a=b), the reversal isn’t necessary.

    unlike using 5[x] insteadof x[5] which just confuses people.

    The writers of compilers actually allow 5[x] as a synonym for x[5]
    (where x is an array)? WTF!

    It’s part of the C language. Personally I’d reject it in a code review,
    but compiler writers don’t really have any choice about supporting it.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to Richard Kettlewell on Wed Feb 16 22:24:23 2022
    "Richard Kettlewell" <invalid@invalid.invalid> wrote in message news:87ee42326l.fsf@LkoBDZeT.terraraq.uk...
    It’s part of the C language. Personally I’d reject it in a code review, but compiler writers don’t really have any choice about supporting it.

    Sure. I do wonder what funny substance K and R were smoking when they came
    up with 5[x] as a valid C syntax - they were definitely having a laugh. I suppose you could say that at pointer level, you are specifying a pointer of value (5*sizeof(int) + &x) for both 5[x] and x[5], but the latter is a damn sight more meaningful.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to All on Wed Feb 16 22:32:53 2022
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message news:20220216215357.137efe85b657c3425d77ae54@eircom.net...
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being used as
    an array (a pointer) on the RHS but as an integer on the LHS. And vice versa for j. I wonder how you would declare i and j so the code would actually compile.

    Even k = ++i[j++] takes some fathoming: you take the value of i[j],
    increment it by 1 and assign it to k, and then increment j. I think... Definitely comes into the category of Too Clever By Three Quarters.

    And as for that mass of apparently-random characters which forms a program
    that prints out the Twelve Days of Christmas - I haven't got the foggiest
    how that works.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From scott@alfter.diespammersdie.us@3:770/3 to druck on Wed Feb 16 23:26:32 2022
    druck <news@druck.org.uk> wrote:
    I saw a similar technique used to protect commercial software written in
    BBC BASIC from being plagiarised. As it was interpreted BASIC it had to
    be supplied in a form which could be read by both humans and the
    computer, but they had renamed every variable and every procedure to a variant of 'ClaresMicroSupplies' with each instance have a different combination of upper and lower case letters. The computer could still
    execute it, but humans just find it impossible to distinguish between
    the variants.

    How many characters were significant in a variable name in that dialect?
    For the Microsoft BASIC implementations you'd find on nearly everything on
    this side of the puddle, only the first two characters are significant. Attempting to obfuscate code by naming a couple of strings SCOTT1$ and
    SCOTT2$ will fail as they're both treated the same as SC$.

    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet?

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to me@privacy.invalid on Thu Feb 17 07:15:59 2022
    On Wed, 16 Feb 2022 22:24:23 -0000
    "NY" <me@privacy.invalid> wrote:

    "Richard Kettlewell" <invalid@invalid.invalid> wrote in message news:87ee42326l.fsf@LkoBDZeT.terraraq.uk...
    It’s part of the C language. Personally I’d reject it in a code review, but compiler writers don’t really have any choice about supporting it.

    Sure. I do wonder what funny substance K and R were smoking when they
    came up with 5[x] as a valid C syntax - they were definitely having a

    They came up with x[y] as syntactic sugar for *(x+y) - they could
    have left it out without reducing the scope of what could be done with C.

    laugh. I suppose you could say that at pointer level, you are specifying
    a pointer of value (5*sizeof(int) + &x) for both 5[x] and x[5], but the latter is a damn sight more meaningful.

    The compiler converts 5[x] into *(5+x) becuase that's the language definition and performs pointer arithmetic. It's more of an unintended consequence of keeping things simple than a deliberate design decision.

    Anyway why is "3rd of array" less meaningful than "array position
    3" ?

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to me@privacy.invalid on Thu Feb 17 07:06:12 2022
    On Wed, 16 Feb 2022 22:32:53 -0000
    "NY" <me@privacy.invalid> wrote:

    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message news:20220216215357.137efe85b657c3425d77ae54@eircom.net...
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being used
    as an array (a pointer) on the RHS but as an integer on the LHS. And vice versa for j. I wonder how you would declare i and j so the code would actually compile.

    i[j] is just syntatic sugar for *(i+j) which is the same as *(j+i) (because addition is commutative) which is j[i] - IOW 3[x] is the same as
    x[3].

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to me@privacy.invalid on Thu Feb 17 08:36:52 2022
    "NY" <me@privacy.invalid> writes:
    "Richard Kettlewell" <invalid@invalid.invalid> wrote:
    It’s part of the C language. Personally I’d reject it in a code
    review, but compiler writers don’t really have any choice about
    supporting it.

    Sure. I do wonder what funny substance K and R were smoking when they
    came up with 5[x] as a valid C syntax - they were definitely having a
    laugh. I suppose you could say that at pointer level, you are
    specifying a pointer of value (5*sizeof(int) + &x) for both 5[x] and
    x[5], but the latter is a damn sight more meaningful.

    It follows from the a[b] = *(a+b), which is not a complicated idea, and
    is a natural one given the code it generates.

    --
    https://www.greenend.org.uk/rjk/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to Ahem A Rivet's Shot on Thu Feb 17 08:48:08 2022
    "NY" <me@privacy.invalid> writes:
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being
    used as an array (a pointer) on the RHS but as an integer on the
    LHS. And vice versa for j. I wonder how you would declare i and j so
    the code would actually compile.

    It’s syntactically legal. 'int i, *j;' would make it compile.

    But it has no meaning. There’s no sequence point between the read of j
    on the left hand side and the change on the right hand side, so it
    violates a constraint in the language spec:

    Between the previous and next sequence point an object shall have
    its stored value modified at most once by the evaluation of an
    expression. Furthermore, the prior value shall be read only to
    determine the value to be stored.

    (C99 text, but later versions have what looks like effectively the same
    rule.)

    --
    https://www.greenend.org.uk/rjk/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jan Panteltje@3:770/3 to Shot on Thu Feb 17 08:29:13 2022
    On a sunny day (Thu, 17 Feb 2022 07:15:59 +0000) it happened Ahem A Rivet's Shot <steveo@eircom.net> wrote in <20220217071559.54716e3e30df759ef3245267@eircom.net>:

    The compiler converts 5[x] into *(5+x) becuase that's the language
    definition and performs pointer arithmetic. It's more of an unintended >consequence of keeping things simple than a deliberate design decision.

    Anyway why is "3rd of array" less meaningful than "array position
    3" ?

    If you put it that way OK.
    But somebody was moaning lately in an other groups that multi-dimensional arrays did not work in C.
    So just for fun I did this in xflir recently:

    header:
    char input_frame_data[Y_PIXELS][X_PIXELS][3];

    code:
    ...
    input_frame_data[y][x][0] = red;
    input_frame_data[y][x][1] = green;
    input_frame_data[y][x][2] = blue;
    ...

    Works perfectly :-)
    How would you write that in that other notation?
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to Jan Panteltje on Thu Feb 17 08:41:29 2022
    On Thu, 17 Feb 2022 08:29:13 GMT
    Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:

    On a sunny day (Thu, 17 Feb 2022 07:15:59 +0000) it happened Ahem A
    Rivet's Shot <steveo@eircom.net> wrote in <20220217071559.54716e3e30df759ef3245267@eircom.net>:

    The compiler converts 5[x] into *(5+x) becuase that's the
    language
    definition and performs pointer arithmetic. It's more of an unintended >consequence of keeping things simple than a deliberate design decision.

    Anyway why is "3rd of array" less meaningful than "array position
    3" ?

    If you put it that way OK.
    But somebody was moaning lately in an other groups that multi-dimensional arrays did not work in C. So just for fun I did this in xflir recently:

    Oh yes they do :)

    How would you write that in that other notation?

    I wouldn't, it doesn't work for multi-dimensional arrays because
    the syntactic sugar is rather more complex.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Jan Panteltje on Thu Feb 17 10:55:42 2022
    On Thu, 17 Feb 2022 08:29:13 +0000, Jan Panteltje wrote:

    If you put it that way OK.
    But somebody was moaning lately in an other groups that
    multi-dimensional arrays did not work in C.

    Surely the only appropriate response to thsat sort of statement is 'Prove
    it or shut up'.

    IOW the moaner must show compilable, runnable code that illustrates the problem. If they can't or won't do that they get rubbished.

    So just for fun I did this in xflir recently:

    header:
    char input_frame_data[Y_PIXELS][X_PIXELS][3];

    code:
    ...
    input_frame_data[y][x][0] = red; input_frame_data[y][x][1] = green;
    input_frame_data[y][x][2] = blue;
    ...

    Works perfectly :-)

    That's a good illustration of how to answer that sort of nonsense.

    See also http://sscce.org/

    Creating an SSCCE is a good suggestion to make in this sort of argument.
    Its also very useful when you're helping someone (or yourself) to fix a
    tricky problem because often just defining it as an SSCCE will help you
    see the solution.

    FWIW I first heard of the SSCCE in connection with writing Java but I
    think it can be usefully applied to any programming or scripting language.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jan Panteltje@3:770/3 to All on Thu Feb 17 11:03:56 2022
    On Tue, 15 Feb 2022 19:38:49 GMT
    Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:

    What helped me a lot in the early days was >https://www.goodreads.com/book/show/3603797-8080-z80-assembly-language
    it also had all the Z80 secret asm statements,
    Also had The C Programming Language by Ritchie & Kernighan, is a free download these days (google).

    There were actually 2 more books that were helpful to me, first of all for the hardware interfacing:
    Microprocessor interfacing techniques by Rodnay Zaks ea Publication date 1979

    And some Unix book I bought when working at a linear accelerator here, they had a PDP? and it fascinated me.
    Was mainly doing hardware back then.
    Nice team, you were allowed some time for personal research, I designed a video digitizer, when was it 1977 or 1978?
    When I demonstrated it somebody told me "Did you know there is now a chip that can do all that?" hehe, indeed there was.
    But few considered sending video over a phone line back then.
    When I installed SLS Linux many years later on my PC all I had to do was lookup that Unix book and I was good to go.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Andy Burns@3:770/3 to Martin Gregorie on Thu Feb 17 11:19:12 2022
    Martin Gregorie wrote:

    the moaner must show compilable, runnable code that illustrates the
    problem. If they can't or won't do that they get rubbished.

    See also http://sscce.org/

    Codepen is a common way of doing that for html+css+js
    but there is an equivalent for C, C++, C# etc

    <https://onlinegdb.com>
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Ahem A Rivet's Shot@3:770/3 to Richard Kettlewell on Thu Feb 17 14:52:08 2022
    On Thu, 17 Feb 2022 08:48:08 +0000
    Richard Kettlewell <invalid@invalid.invalid> wrote:

    "NY" <me@privacy.invalid> writes:
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being
    used as an array (a pointer) on the RHS but as an integer on the
    LHS. And vice versa for j. I wonder how you would declare i and j so
    the code would actually compile.

    It’s syntactically legal. 'int i, *j;' would make it compile.

    But it has no meaning. There’s no sequence point between the read of j
    on the left hand side and the change on the right hand side, so it
    violates a constraint in the language spec:

    Yep undefined behaviour.

    --
    Steve O'Hara-Smith
    Odds and Ends at http://www.sohara.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Dennis Lee Bieber@3:770/3 to All on Thu Feb 17 13:34:28 2022
    On Wed, 16 Feb 2022 22:32:53 -0000, "NY" <me@privacy.invalid> declaimed the following:

    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message >news:20220216215357.137efe85b657c3425d77ae54@eircom.net...
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being used as >an array (a pointer) on the RHS but as an integer on the LHS. And vice versa >for j. I wonder how you would declare i and j so the code would actually >compile.

    I'd object to it just on the basis that it is ambiguous -- depending upon what order the compiler computes the subscripted terms. Did the
    compiler determine/cache the address for j[i] first, and then do the increment/subscripts on the right side... Did it compute the right side
    first before applying the values to the left, ... etc.


    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Dennis Lee Bieber@3:770/3 to All on Thu Feb 17 13:48:01 2022
    On Wed, 16 Feb 2022 23:26:32 GMT, scott@alfter.diespammersdie.us declaimed
    the following:


    How many characters were significant in a variable name in that dialect?
    For the Microsoft BASIC implementations you'd find on nearly everything on >this side of the puddle, only the first two characters are significant. >Attempting to obfuscate code by naming a couple of strings SCOTT1$ and >SCOTT2$ will fail as they're both treated the same as SC$.

    As I recall, that tended to derive from Kemeny&Kurtz BASIC... <a..z>[<0..9>][$] (as I recall, original K&K BASIC didn't provide
    punctuation to differentiate integer<>float<>double, only the $ for
    string). One alphabetic followed by optional single digit, followed by
    optional string indicator. Also DIM statements allocated space for one
    element more than the number provided, as subscript 0 was valid.


    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Dennis Lee Bieber on Thu Feb 17 19:40:20 2022
    On Thu, 17 Feb 2022 13:48:01 -0500, Dennis Lee Bieber wrote:

    As I recall, that tended to derive from Kemeny&Kurtz BASIC... <a..z>[<0..9>][$] (as I recall, original K&K BASIC didn't provide
    punctuation to differentiate integer<>float<>double, only the $ for
    string). One alphabetic followed by optional single digit, followed by optional string indicator. Also DIM statements allocated space for one element more than the number provided, as subscript 0 was valid.


    Ugh! Thankfully, the first interactive language I used was JEAN (JOSS Extensively Adapted for Nineteenhundred), which ran under the MINIMOP timesharing system, on ICL 1900s with teletypes connected via a uniplex
    or multiplex switch. JOSS itself was written for Rand's JOHNIAC computer

    JEAN was nice to edit on a teletype since it used real line numbers: you
    could always insert another line between existing ones.

    Its only real drawbacks were its single character variable names, so a
    program could only have 26 variables though they could be arrays, and its conditional syntax:

    1.1 Type "Hello, World!" if X=5

    which meant there was no 'else' branch.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From NY@3:770/3 to Martin Gregorie on Thu Feb 17 22:07:18 2022
    "Martin Gregorie" <martin@mydomain.invalid> wrote in message news:sum8b4$r6d$1@dont-email.me...
    On Thu, 17 Feb 2022 13:48:01 -0500, Dennis Lee Bieber wrote:

    As I recall, that tended to derive from Kemeny&Kurtz BASIC...
    <a..z>[<0..9>][$] (as I recall, original K&K BASIC didn't provide
    punctuation to differentiate integer<>float<>double, only the $ for
    string). One alphabetic followed by optional single digit, followed by
    optional string indicator. Also DIM statements allocated space for one
    element more than the number provided, as subscript 0 was valid.


    Ugh! Thankfully, the first interactive language I used was JEAN (JOSS Extensively Adapted for Nineteenhundred), which ran under the MINIMOP timesharing system, on ICL 1900s with teletypes connected via a uniplex
    or multiplex switch. JOSS itself was written for Rand's JOHNIAC computer

    JEAN was nice to edit on a teletype since it used real line numbers: you could always insert another line between existing ones.

    Its only real drawbacks were its single character variable names, so a program could only have 26 variables though they could be arrays, and its conditional syntax:

    1.1 Type "Hello, World!" if X=5

    which meant there was no 'else' branch.

    My first introduction to computer programming was another ICL language,
    CESIL (Computer Education in Schools Instructive Language). That was at
    ICL's training centre, Beaumont, in Old Windsor (near the Bells of Ouzeley pub). It was in the scorching hot summer of 1976 and it was a toss-up
    between having the windows open so we didn't get *too* hot, and having them closed so we could hear the lecturer and he didn't get drowned out by the incoming and outgoing planes at Heathrow.

    Only after a day of CESIL did we move on to BASIC. All our coding was done
    with pencil and squared coding sheets; these were then collected up and
    typed onto punched cards which were taken to another site nearby to be run
    on the computer, with listings returned the following day. Not very interactive! The only interactive time we got was on a teletype that was
    linked by acoustic coupler to a mainframe, on which we played the
    lunar-landing game.

    I wrote an article for the school magazine about my experiences on the
    course, but some dimbo "corrected" CESIL to CECIL, so I was plagued by
    people saying "but Computer Education in Schools Instructive Language should have an S, not a C, in the middle".

    It was a sign of the times that I opened the article with "The other day, my neighbour received an electricity bill for £376", as if that was a preposterous amount for a quarterly bill, which was due to a "computer
    error" that was probably operator error. Now a quarterly bill for £376 would be fairly low. How times change.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From A. Dumas@3:770/3 to me@privacy.invalid on Thu Feb 17 22:55:49 2022
    NY <me@privacy.invalid> wrote:
    It was in the scorching hot summer of 1976 [...]
    It was a sign of the times that I opened the article with "The other day, my neighbour received an electricity bill for £376", as if that was a preposterous amount for a quarterly bill, which was due to a "computer
    error" that was probably operator error. Now a quarterly bill for £376 would be fairly low. How times change.

    £376 in 1976 is £2880 today, says https://www.bankofengland.co.uk/monetary-policy/inflation/inflation-calculator

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to All on Thu Feb 17 22:49:54 2022
    On Thu, 17 Feb 2022 22:07:18 +0000, NY wrote:

    My first introduction to computer programming was another ICL language,
    CESIL (Computer Education in Schools Instructive Language). That was at
    ICL's training centre, Beaumont, in Old Windsor (near the Bells of
    Ouzeley pub). It was in the scorching hot summer of 1976 and it was a
    toss-up between having the windows open so we didn't get *too* hot, and having them closed so we could hear the lecturer and he didn't get
    drowned out by the incoming and outgoing planes at Heathrow.

    Only after a day of CESIL did we move on to BASIC. All our coding was
    done with pencil and squared coding sheets; these were then collected up
    and typed onto punched cards which were taken to another site nearby to
    be run on the computer, with listings returned the following day. Not
    very interactive! The only interactive time we got was on a teletype
    that was linked by acoustic coupler to a mainframe, on which we played
    the lunar-landing game.

    I wrote an article for the school magazine about my experiences on the course, but some dimbo "corrected" CESIL to CECIL, so I was plagued by
    people saying "but Computer Education in Schools Instructive Language
    should have an S, not a C, in the middle".

    It was a sign of the times that I opened the article with "The other
    day, my neighbour received an electricity bill for £376", as if that was
    a preposterous amount for a quarterly bill, which was due to a "computer error" that was probably operator error. Now a quarterly bill for £376
    would be fairly low. How times change.


    I missed CESIL by quite a few years. My introduction to programming was
    on my University's Elliott 503, a scientific computer that was programmed
    in Algol 60. Its main claims to fame were that it was one of the first semiconductor-based computers, its logic implemented entirely in discrete transistors (not an IC anywhere in it, so it occupied four very large
    grey cabinets). It was slightly faster at floating point arithmetic than
    it was at integer operations: after all, it WAS designed for scientific
    and engineering workloads.

    After that I joined ICL's computer service bureau and learnt PLAN, the assembler used on all 1900 series machines, followed about a year later
    by COBOL. That was also where I discovered the JEAN language.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to Dennis Lee Bieber on Fri Feb 18 10:12:40 2022
    Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
    "NY" <me@privacy.invalid> declaimed the following:
    "Ahem A Rivet's Shot" <steveo@eircom.net> wrote in message >>news:20220216215357.137efe85b657c3425d77ae54@eircom.net...
    j[i] = ++i[j++];

    That makes my brain hurt. But is it syntactically legal? i is being used as >>an array (a pointer) on the RHS but as an integer on the LHS. And vice versa >>for j. I wonder how you would declare i and j so the code would actually >>compile.

    I'd object to it just on the basis that it is ambiguous -- depending upon what order the compiler computes the subscripted terms. Did the
    compiler determine/cache the address for j[i] first, and then do the increment/subscripts on the right side... Did it compute the right side
    first before applying the values to the left, ... etc.

    It’s not just ambiguous, in the sense of there being a set of reasonable possible interpretations: it’s completely undefined. In C99 terms, it violates the constraint in s6.5#2, and all constraint violations are
    undefined behavior (s4#2).

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From druck@3:770/3 to scott@alfter.diespammersdie.us on Fri Feb 18 22:13:23 2022
    On 16/02/2022 23:26, scott@alfter.diespammersdie.us wrote:
    druck <news@druck.org.uk> wrote:
    I saw a similar technique used to protect commercial software written in
    BBC BASIC from being plagiarised. As it was interpreted BASIC it had to
    be supplied in a form which could be read by both humans and the
    computer, but they had renamed every variable and every procedure to a
    variant of 'ClaresMicroSupplies' with each instance have a different
    combination of upper and lower case letters. The computer could still
    execute it, but humans just find it impossible to distinguish between
    the variants.

    How many characters were significant in a variable name in that dialect?
    For the Microsoft BASIC implementations you'd find on nearly everything on this side of the puddle, only the first two characters are significant. Attempting to obfuscate code by naming a couple of strings SCOTT1$ and SCOTT2$ will fail as they're both treated the same as SC$.

    BBC BASIC was written by someone who knew what they were doing (see
    ARM), unlike the author of Microsoft BASIC. All characters of variables
    and procedures where significant, and lookups were optimised by using
    the first letter to index separate lists.

    ---druck

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)