The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* Re: [TUHS] # (was Re: sh: cmd | >file)
@ 2020-01-08  5:20 Brian Walden
  2020-01-08  6:25 ` Bakul Shah
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Walden @ 2020-01-08  5:20 UTC (permalink / raw)
  To: tuhs

Dave Horsfall wrote:
>On Tue, 7 Jan 2020, Bakul Shah wrote:
>
>> In Algol68  # ... # is one of the forms for block comments!
>
>Interesting...  All we had at university though was ALGOL W (as far as I
>know; there were several languages that mere students could not use, such
>as FORTRAN H).

Yes, but when was it implemented? Kernighan is first ever if it is not
before 1974. So I decided to look and it took me down a rabbit hole of
ALGOL taht leads back to Bourne shell and then right back to # (but in C)

By reading the ALGOL 68 wiki page, the laguange seemed to have had a
character set problem since day one, and it seems if you didn't have the
cent-sign you were to use PR for pragmat for comments. And since it
had problems it was continually extened. I just cant find when # was defined.

I looked at various old implementations (none pre 1974 list #) --

- CDC's ALGOL 68 compiler from 1975 you could only use use PR .. PR
  (both # and CO were not defined)
   http://www.bitsavers.org/pdf/cdc/Tom_Hunter_Scans/Algol_68_version_1_Reference_Manual_RevB.pdf

- The official revised ALGOL86 spec from 1978 lists all these ways to enter
  them (bottom of page 112) in this order --
  brief comment symbol:         cent-sign
  bold comment symbol:          comment
  style 1 comment symbol:       co
  style 2 comment symbol:       #
  bold pragmat symbol:          pragmat
  style 1 pragmat symbol:       pr
  seeing # is "style 2" it looks like a later extention to me
  http://www.softwarepreservation.org/projects/ALGOL/report/Algol68_revised_report-AB.pdf

- ALGOL68/19 from 1975 list these 4 symbols as comments: # % co pr
  http://www.softwarepreservation.org/projects/ALGOL/manual/Gennart_Louis-Algol_         68_19_Reference_Manual.pdf

- DECs ALGOL (1976 printing but first released was 1971) for system10 uses
  a ! for a comment as # means "not equal" --
  http://www.bitsavers.org/www.computer.museum.uq.edu.au/pdf/DEC-10-LALMA-B-D%20         decsystem10%20ALGOL%20Programmer's%20Reference%20Manual.pdf

- CMU's ALGOL68S from 1978 list all these ways --
  co            comment
  comment       comment
  pr            pragmat
  pragmat       pragmat
  #             (comment symbol) comment
  ::            (pragmat symbol) pragmat
  (its for UNIX v6 or v7 so not surprising # is a comment)
  http://www.softwarepreservation.org/projects/ALGOL/manual/a68s.txt/view

- Rutgers ALGOL 68 interprter from 1987 for UNIX does not implement
  PR nor PRAMAT and says comments are # CO or COMMENT
  https://www.renyi.hu/~csirmaz/algol-68/linux/manual

I could not find a freely accessible manual for ALGOL68R (very 1st one) nor
Cambridge's ALGOL68C. What's intresting here is Stephen Bourne was on the
team that made ALGOL68C before he move to Bell Labs. It'd be pretty funny
if he implemented a language that there were 7 or 8 ways to enter a comment
(cent, co, comment, pr, pragmat, #, ::, %) yet there were zero ways
to enter a comment in the Bourne shell.

Also the style of "COMMENT put a note here COMMENT" is very un-ALGOL like
(with DO .. OD, IF .. FI) shouldn't it be like this?
    COMMENT put a note here TNEMMOC
    CO put a note here OC
    PRAGMAT directive here TAMGARP
    PR directive here RP

So then I remembered Bourne used the C preprocssor to make C like ALGOL when
he wrote the shell. If you've never seen it, his C looks like this --

case TSW:
        BEGIN
           REG STRING   r = mactrim(t->swarg);
           t=t->swlst;
           WHILE t
           DO   ARGPTR          rex=t->regptr;
                WHILE rex
                DO      REG STRING      s;
                        IF gmatch(r,s=macro(rex->argval)) ORF (trim(s), eq(r,s))
                        THEN    execute(t->regcom,0);
                                t=0; break;
                        ELSE    rex=rex->argnxt;
                        FI
                OD
                IF t THEN t=t->regnxt FI
           OD
        END
        break;
ENDSW

So I wanted to see if he remapped C comments /* */
I am not even sure you could even do that with the C preprocessor
but took alook anywy and in
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/xec.c
It's first lines are this --

#
/*
 * UNIX shell
 *
 * S. R. Bourne
 * Bell Telephone Laboratories
 *
 */

#include        "defs.h"
#include        "sym.h"

So nope, just regular C comments (which came from PL/I btw which was
what multics was programmed in)

But look! The very first line of that file! It is
a single # sitting all by itself.  Why? you ask. Well this is a hold
over from when the C preprocessor was new. C orginally did not
have it and was added later. PL/I had a %INCLUDE so Ritchie eventaully
made a #include -- but pre 7th Edition the C preprocessor would not be
inkoved unless the very first character of the C source file was an #
Since v7 the preprocessor always run on it. The first C preprocessor
was Ritchie's work with no nested includes and no macros. v7's was by
John Reiser which added those parts.

that 1st line with a single # sitting by itself reminds me of the
csh construct as well.
-Brian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-08  5:20 [TUHS] # (was Re: sh: cmd | >file) Brian Walden
@ 2020-01-08  6:25 ` Bakul Shah
  0 siblings, 0 replies; 10+ messages in thread
From: Bakul Shah @ 2020-01-08  6:25 UTC (permalink / raw)
  To: Brian Walden; +Cc: tuhs

> On Jan 7, 2020, at 9:20 PM, Brian Walden <tuhs@cuzuco.com> wrote:
> 
> Dave Horsfall wrote:
>> On Tue, 7 Jan 2020, Bakul Shah wrote:
>> 
>>> In Algol68  # ... # is one of the forms for block comments!
>> 
>> Interesting...  All we had at university though was ALGOL W (as far as I
>> know; there were several languages that mere students could not use, such
>> as FORTRAN H).
> 
> Yes, but when was it implemented? Kernighan is first ever if it is not
> before 1974. So I decided to look and it took me down a rabbit hole of
> ALGOL taht leads back to Bourne shell and then right back to # (but in C)

Tanenbaum’s “A tutorial on Algol 68” published in Computing Surveys, June 1976
mentions that # is one of the (four) ways a comment may be enclosed.

https://research.vu.nl/ws/portalfiles/portal/74119499/11057

An earlier paper “Algol68 with fewer tears” by C H Lindsey, 1972
also mentions # as an alternate symbol.

https://academic.oup.com/comjnl/article-pdf/15/2/176/1002964/15-2-176.pdf


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-07  0:39   ` Warner Losh
@ 2020-01-08  2:44     ` Greg A. Woods
  0 siblings, 0 replies; 10+ messages in thread
From: Greg A. Woods @ 2020-01-08  2:44 UTC (permalink / raw)
  To: The Unix Heritage Society mailing list

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

At Mon, 6 Jan 2020 17:39:39 -0700, Warner Losh <imp@bsdimp.com> wrote:
Subject: Re: [TUHS] # (was Re: sh: cmd | >file)
>
>
> Or you might have cut and paste the commands from a script to test
> something, or to redo something by hand that failed for some reason.

Cut & Paste?

Most of us couldn't do that until the very late 1980's at earliest!

The poor man's cut&paste was to do something like 'sed -n 3,9p script |
sh', but I don't think I ever did that with csh in the days when a '#'
comment was for scripts only, so I don't know if old csh treated a pipe
on stdin as a script or not.

--
					Greg A. Woods <gwoods@acm.org>

Kelowna, BC     +1 250 762-7675           RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>     Avoncote Farms <woods@avoncote.ca>

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-07 22:26   ` Bakul Shah
@ 2020-01-07 22:56     ` Dave Horsfall
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Horsfall @ 2020-01-07 22:56 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

On Tue, 7 Jan 2020, Bakul Shah wrote:

> In Algol68  # ... # is one of the forms for block comments!

Interesting...  All we had at university though was ALGOL W (as far as I 
know; there were several languages that mere students could not use, such 
as FORTRAN H).

-- Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-06 22:50 ` Dave Horsfall
  2020-01-07  0:39   ` Warner Losh
  2020-01-07 15:24   ` Clem Cole
@ 2020-01-07 22:26   ` Bakul Shah
  2020-01-07 22:56     ` Dave Horsfall
  2 siblings, 1 reply; 10+ messages in thread
From: Bakul Shah @ 2020-01-07 22:26 UTC (permalink / raw)
  To: Dave Horsfall; +Cc: The Eunuchs Hysterical Society

> On Jan 6, 2020, at 2:51 PM, Dave Horsfall <dave@horsfall.org> wrote:
> 
> On Mon, 6 Jan 2020, Brian Walden wrote:
> 
>> Also before you say wait! ALGOL uses # as comment and is older than Kernighan' ratfor(1). [...]
> 
> Funny; I recall ALGOL using "comment ... ;" or was that ALGOLW (which I loved using; I wish I still had my ALGOLW book)?

In Algol68  # ... # is one of the forms for block comments!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-07 15:24   ` Clem Cole
@ 2020-01-07 22:13     ` Dave Horsfall
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Horsfall @ 2020-01-07 22:13 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 598 bytes --]

On Tue, 7 Jan 2020, Clem Cole wrote:

> Algol-W   From, the Sites book, (Page 10, Section 1 'Terminology)  [Dave,
> I'll send you the PDF offline]. 

For the record, it was received OK; thanks!

>             The symbol comment followed by any sequence of
>             characters not -containing semicolons, followed by a
>             semicolon, is called a comment. A comment has no
>             effect on the meaning of a program, and is ignored
>             during execution of the program. 

For the benefit of the OP, here is no mention of "#" being a comment in 
ALGOL(W).

-- Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-06 22:50 ` Dave Horsfall
  2020-01-07  0:39   ` Warner Losh
@ 2020-01-07 15:24   ` Clem Cole
  2020-01-07 22:13     ` Dave Horsfall
  2020-01-07 22:26   ` Bakul Shah
  2 siblings, 1 reply; 10+ messages in thread
From: Clem Cole @ 2020-01-07 15:24 UTC (permalink / raw)
  To: Dave Horsfall; +Cc: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

On Mon, Jan 6, 2020 at 5:51 PM Dave Horsfall <dave@horsfall.org> wrote:

> Funny; I recall ALGOL using "comment ... ;" or was that ALGOLW (which I
> loved using; I wish I still had my ALGOLW book)?
>
Algol-W   From, the Sites book, (Page 10, Section 1 'Terminology)  [Dave,
I'll send you the PDF offline].

The symbol *comment* followed by any sequence of characters not -containing
semicolons, followed by a semicolon, is called a *comment*. A comment has
no effect on the meaning of a program, and is ignored during execution of
the program.

[-- Attachment #2: Type: text/html, Size: 1774 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-06 22:50 ` Dave Horsfall
@ 2020-01-07  0:39   ` Warner Losh
  2020-01-08  2:44     ` Greg A. Woods
  2020-01-07 15:24   ` Clem Cole
  2020-01-07 22:26   ` Bakul Shah
  2 siblings, 1 reply; 10+ messages in thread
From: Warner Losh @ 2020-01-07  0:39 UTC (permalink / raw)
  To: Dave Horsfall; +Cc: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

On Mon, Jan 6, 2020 at 3:51 PM Dave Horsfall <dave@horsfall.org> wrote:

> On Mon, 6 Jan 2020, Brian Walden wrote:
>
> > csh(1) was wrtten around 1978 and yes # as a comment was only for
> > scrtipts, think it was why would you need to comment interactively?
>
> Why would you *not* want to?  You've just made "#" asymmetric in its
> behaviour; in the meantime the parser just sees an unescaped "#" and
> ignores everything after that, without regard to context.
>
> You might also be using "script" e.g.
>
>      script
>      blah blah
>      # Now here I do something funky
>      *really* funky stuff
>      ^D
>

Or you might have cut and paste the commands from a script to test
something, or to redo something by hand that failed for some reason.

Warner


> [...]
>
> > Also before you say wait! ALGOL uses # as comment and is older than
> > Kernighan' ratfor(1). [...]
>
> Funny; I recall ALGOL using "comment ... ;" or was that ALGOLW (which I
> loved using; I wish I still had my ALGOLW book)?
>
> -- Dave
>

[-- Attachment #2: Type: text/html, Size: 1675 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [TUHS] # (was Re: sh: cmd | >file)
  2020-01-06  6:30 Brian Walden
@ 2020-01-06 22:50 ` Dave Horsfall
  2020-01-07  0:39   ` Warner Losh
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dave Horsfall @ 2020-01-06 22:50 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

On Mon, 6 Jan 2020, Brian Walden wrote:

> csh(1) was wrtten around 1978 and yes # as a comment was only for 
> scrtipts, think it was why would you need to comment interactively?

Why would you *not* want to?  You've just made "#" asymmetric in its 
behaviour; in the meantime the parser just sees an unescaped "#" and 
ignores everything after that, without regard to context.

You might also be using "script" e.g.

     script
     blah blah
     # Now here I do something funky
     *really* funky stuff
     ^D

[...]

> Also before you say wait! ALGOL uses # as comment and is older than 
> Kernighan' ratfor(1). [...]

Funny; I recall ALGOL using "comment ... ;" or was that ALGOLW (which I 
loved using; I wish I still had my ALGOLW book)?

-- Dave

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [TUHS] # (was Re: sh: cmd | >file)
@ 2020-01-06  6:30 Brian Walden
  2020-01-06 22:50 ` Dave Horsfall
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Walden @ 2020-01-06  6:30 UTC (permalink / raw)
  To: tuhs

A bit more on this.
csh(1) was wrtten around 1978 and yes # as a comment was only for
scrtipts, think it was why would you need to comment interactively?
And the # as an addition to be a comment in Bourne shell had to be around 1980
as that is when Dennis Ritchie added #! to exec(2) in the kernel. From this
point on this forced all UNIX scripting languages to use # as a comment as
it just exec'd the first string after the #! with the name of the current
file being exec'd as the single argument. So things like perl(1) and python(1)
had to use # if they wanted the #! mechanism to work for them too.

So this worked great for shell scripts, it didn't work for awk(1) nor sed(1)
nor s(1)(that is R(1) now) scripts (all needed a -f for input from file)
nor dc(1) scripts as dc had no comment character.
While Research UNIX got !# in 1980, this was after the 7th Edition release
and the 8th Edition wasn't released until 1985), BSD got it around 1982-83,
and System V didn't implement it until 1988. Eventully #! was extented
so #!/usr/bin/awk -f would work.

Also Bill Joy was the first to use # as a comment character in an /etc config
file for his /etc/ttycap (which became /etc/termcap) for vi(1). Most configs
did not have a comment at all at that time, while /etc/master used a * as a
comment (SCCS used * as a comment too btw)

Also before you say wait! ALGOL uses # as comment and is older than
Kernighan' ratfor(1). This is a later addition. The original used the EBCDIC
cent sign character to start and another cent sign to end the comment
(i.e. programmer's two cents). If you were on an ASCII system this became
"co" (for comment) as the original ASCII does not have a cent sign

-Brian

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-01-08  6:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08  5:20 [TUHS] # (was Re: sh: cmd | >file) Brian Walden
2020-01-08  6:25 ` Bakul Shah
  -- strict thread matches above, loose matches on Subject: below --
2020-01-06  6:30 Brian Walden
2020-01-06 22:50 ` Dave Horsfall
2020-01-07  0:39   ` Warner Losh
2020-01-08  2:44     ` Greg A. Woods
2020-01-07 15:24   ` Clem Cole
2020-01-07 22:13     ` Dave Horsfall
2020-01-07 22:26   ` Bakul Shah
2020-01-07 22:56     ` Dave Horsfall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).