From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, NICE_REPLY_A,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23727 invoked from network); 3 Feb 2022 04:01:03 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 3 Feb 2022 04:01:03 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id B19F59D6CD; Thu, 3 Feb 2022 14:00:59 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 2E6129B6B0; Thu, 3 Feb 2022 14:00:27 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b8WKpi2u"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 762F09B6B0; Thu, 3 Feb 2022 14:00:24 +1000 (AEST) Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by minnie.tuhs.org (Postfix) with ESMTPS id E9B0B9B682 for ; Thu, 3 Feb 2022 14:00:23 +1000 (AEST) Received: by mail-oi1-f175.google.com with SMTP id x193so2294381oix.0 for ; Wed, 02 Feb 2022 20:00:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:references:in-reply-to; bh=7QPGTr6H7JholcCXn+xyd4/UZq97KovH8c1Eg0ptaFI=; b=b8WKpi2uVKAFNL6c5W04NUbhUw9v1QssXvIz/rTou5E/WsPk/zN6BKuQy9J1G7Q2Rn +UWdzkd/2D4aEj7TOCmIEzHtmLANFWBaWk3EEHp2p/VKM3vu53dSPjW66HHJgcXcauBz KaxhMPfXAoKKIePHuBeC8rIyoX2UziydDQBdLcXXJX6q1wjCr0tDCeFsQiUQoVe7j5kn 6Az7+oS+vzb5V8X/IsalGhxzG5BdNnQDHaxjSxROuNu9VZa9r+MhfxF40SPbCGtCkTHx EFy/I+ms4hykROTwNfw+JXnW1SRtdM8HClGyh4aqj5rIfIA8jN9eSo5GqhpQnvczObVz veiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to; bh=7QPGTr6H7JholcCXn+xyd4/UZq97KovH8c1Eg0ptaFI=; b=TMVCoo4KCyu8Kmi9elCozzNNEb3tobYS4m4nBJVFZrivXqZfSwjn1lKai+Tz/c2B9d JCCPb33dQtcBFSnAn+J4i75wdNF6DtZBaJ3hbeVYbWf5DWaTAE2JARZD32yN3XloD/l0 fOofF5DC5D6xG8O2Co+tywTbRU93JsJ7R2x1WIRibi5+2TqejPs9dUq62+IrgtQx3WKr gxc2fXNIgXrYCU/7v8l1I8aY+9ugVJj5zE3uN7e2ropri1DyXpfSuhmnLFKqe73qj5MP tC0xgBPAlmE0suGFsh6BHqecgM5uakRNKKmCnD5W3uTECkG5yPIs7rELNm8uDIduuLfj uZrw== X-Gm-Message-State: AOAM533LqvZpPrsGp7iJo39DT8sYVljxfUF1t0rb5wuXcPSu/CQ/Fbg8 2+Whid4dE+rTDvlzoi5RYnhSeRrPXkc= X-Google-Smtp-Source: ABdhPJzv0/upfrLrBlDxCHfhmeV427QceqVI3lR8rW55eWlzvRvAU9Kk0ykFt5SNSCMp6jyXOZzLhg== X-Received: by 2002:a05:6808:118e:: with SMTP id j14mr6371802oil.196.1643860822823; Wed, 02 Feb 2022 20:00:22 -0800 (PST) Received: from [192.168.1.85] (035-134-121-000.res.spectrum.com. [35.134.121.0]) by smtp.gmail.com with ESMTPSA id e68sm11276026otb.10.2022.02.02.20.00.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Feb 2022 20:00:22 -0800 (PST) Content-Type: multipart/alternative; boundary="------------bw8BjIhuNF00xb5fSONCo6nE" Message-ID: Date: Wed, 2 Feb 2022 22:00:21 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US From: Will Senn To: TUHS main list References: In-Reply-To: Subject: Re: [TUHS] ratfor vibe X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" This is a multi-part message in MIME format. --------------bw8BjIhuNF00xb5fSONCo6nE Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/31/22 2:46 PM, Will Senn wrote: > All, > > I have been doing some language exploration in v7/4.3bsd and came > across Software Tools (not the pascal version). It's written using > ratfor, which I had seen in the v7 UPM. I fired up v7 and tried my > hand at the first example: I thought I'd close the loop on the language side of this thread. I am happy to report that ratfor (and fortran) is alive and well. It works on my mac! The Software Tools book is awesome, if challenging. The first chapter is particularly challenging as it takes a bit to figure out where the authors are coming from and what they include, exclude, and highlight... and why. The key to understanding the book, as a modern reader, is to understand that the authors assume their readers are fortran (or PL/I) programmers.  Because of this, they don't explain anything that would be obvious to said programmers (read, write, LUNs, Hollerith cards, format, etc). In addition, they will push down details of implementation until they practically disappear (think singularity... annoyingly consistent in this regard). When they say something like "EOF is a symbolic constant... We won't tell you what its value is, since the particular value doesn't matter", they really mean it. Unfortunately, in order to actually implement stuff, you gotta know what every symbolic constant and macro replacement is :). For example, even in the tiny copy program example, from the introductory chapter, once you include the primitive getc and putc subroutines, there are 7 symbolic constants: MAXLINE, MAXCARD, NEWLINE, STDIN, STDOUT, EOF, SPACE and character, which is really an integer and gets replaced with integer by some mythical preprocessor (chapter 8). Anyhow, in the modern world, MAXLINE and MAXCARD don't really have meaning, but they can magically be treated as lines of a file, the rest do have meaning, but they don't evaluate to the same things in Fortran-land as in modern-land. STDIN is 5 and STDOUT is 6 (card reader and punch LUNs, again some magic that lets them be treated as terminal input and output),  EOF is -1, SPACE is 32, NEWLINE is 10. Anyhow, long story just a bit shorter, replace those constants, swap character for integer, and combine getc, putc, and copy and yahoo, a working copy program that works in v7, 4.xBSD, and Mac OS X Mojave (and BSD, etc), without any further modifications... at all. Included for the curioius (copynew.r): # on v7 # $ ratfor -C copynew.r > copynew.f # $ f77 -o copynew copynew.f # on mac # $ ratfor77 -C copynew.r > copynew.f # $ gfortran -o copynew copynew.f # $ ./copynew # This is a test. # This is a test. # CTRL-d # $ # getc (simple version) - get characters from standard input         integer function getc(c)         integer buf(81), c         integer i, lastc         data lastc /81/,buf(81) /10/         lastc = lastc + 1         if(lastc > 81) {                 read(5, 100, end=10) (buf(i), i = 1, 80)                         100 format(80 a 1)                 lastc = 1                 }         c = buf(lastc)         getc = c         return 10      c = -1         getc = -1         return         end # putc (simple version) - put characters on the standard output         subroutine putc(c)         integer buf(80), c         integer i, lastc         data lastc /0/         if (lastc > 80 | c == 10) {                 for (i = lastc + 1; i <= 80; i = i + 1)                         buf(i) = 32                 write(6, 100) (buf(i), i = 1, 80)                         100 format(80 a 1)                 lastc = 0                 }         if (c != 10) {                 lastc = lastc + 1                 buf(lastc) = c                 }         return         end # copy - copy input characters to output         integer getc         integer c         while(getc(c) != -1)                 call putc(c)         stop         end Of course, it's criminal to have all those hardcoded magic numbers, wouldn't it be swell if there were some sort of macro facility?... oh, wait, that's what Chapter 8's all about... I can't wait. Will --------------bw8BjIhuNF00xb5fSONCo6nE Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 1/31/22 2:46 PM, Will Senn wrote:
All,

I have been doing some language exploration in v7/4.3bsd and came across Software Tools (not the pascal version). It's written using ratfor, which I had seen in the v7 UPM. I fired up v7 and tried my hand at the first example:


I thought I'd close the loop on the language side of this thread. I am happy to report that ratfor (and fortran) is alive and well. It works on my mac! The Software Tools book is awesome, if challenging. The first chapter is particularly challenging as it takes a bit to figure out where the authors are coming from and what they include, exclude, and highlight... and why. The key to understanding the book, as a modern reader, is to understand that the authors assume their readers are fortran (or PL/I) programmers.  Because of this, they don't explain anything that would be obvious to said programmers (read, write, LUNs, Hollerith cards, format, etc). In addition, they will push down details of implementation until they practically disappear (think singularity... annoyingly consistent in this regard). When they say something like "EOF is a symbolic constant... We won't tell you what its value is, since the particular value doesn't matter", they really mean it. Unfortunately, in order to actually implement stuff, you gotta know what every symbolic constant and macro replacement is :).

For example, even in the tiny copy program example, from the introductory chapter, once you include the primitive getc and putc subroutines, there are 7 symbolic constants: MAXLINE, MAXCARD, NEWLINE, STDIN, STDOUT, EOF, SPACE and character, which is really an integer and gets replaced with integer by some mythical preprocessor (chapter 8). Anyhow, in the modern world, MAXLINE and MAXCARD don't really have meaning, but they can magically be treated as lines of a file, the rest do have meaning, but they don't evaluate to the same things in Fortran-land as in modern-land. STDIN is 5 and STDOUT is 6 (card reader and punch LUNs, again some magic that lets them be treated as terminal input and output),  EOF is -1, SPACE is 32, NEWLINE is 10. Anyhow, long story just a bit shorter, replace those constants, swap character for integer, and combine getc, putc, and copy and yahoo, a working copy program that works in v7, 4.xBSD, and Mac OS X Mojave (and BSD, etc), without any further modifications... at all.

Included for the curioius (copynew.r):
# on v7
# $ ratfor -C copynew.r > copynew.f
# $ f77 -o copynew copynew.f
# on mac

# $ ratfor77 -C copynew.r > copynew.f
# $ gfortran -o copynew copynew.f
# $ ./copynew
# This is a test.
# This is a test.
# CTRL-d
# $

# getc (simple version) - get characters from standard input
        integer function getc(c)
        integer buf(81), c
        integer i, lastc
        data lastc /81/,buf(81) /10/

        lastc = lastc + 1
        if(lastc > 81) {
                read(5, 100, end=10) (buf(i), i = 1, 80)
                        100 format(80 a 1)
                lastc = 1
                }
        c = buf(lastc)
        getc = c
        return
        
10      c = -1
        getc = -1
        return
        end

# putc (simple version) - put characters on the standard output
        subroutine putc(c)
        integer buf(80), c
        integer i, lastc
        data lastc /0/

        if (lastc > 80 | c == 10) {
                for (i = lastc + 1; i <= 80; i = i + 1)
                        buf(i) = 32
                write(6, 100) (buf(i), i = 1, 80)
                        100 format(80 a 1)
                lastc = 0
                }
        if (c != 10) {
                lastc = lastc + 1
                buf(lastc) = c
                }
        return
        end

# copy - copy input characters to output
        integer getc
        integer c

        while(getc(c) != -1)
                call putc(c)
        stop
        end

Of course, it's criminal to have all those hardcoded magic numbers, wouldn't it be swell if there were some sort of macro facility?... oh, wait, that's what Chapter 8's all about... I can't wait.

Will
--------------bw8BjIhuNF00xb5fSONCo6nE--