rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* comments, newlines
@ 1992-03-11  7:19 schwartz
  0 siblings, 0 replies; 8+ messages in thread
From: schwartz @ 1992-03-11  7:19 UTC (permalink / raw)
  To: rc


Consider this rc script:

x=(1 \
#  2 \
   3)

Using Byron's rc, this gets a syntax error.  Does Tom Duff's rc behave
similarly?   This doesn't seem like useful behavior to me: it makes it
too hard to use comments in a natural way.



^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: comments, newlines
@ 1992-03-11 17:27 haahr
  1992-03-12 22:05 ` David J. Fiander
  0 siblings, 1 reply; 8+ messages in thread
From: haahr @ 1992-03-11 17:27 UTC (permalink / raw)
  To: schwartz; +Cc: rc mailing list

the reason that
	x=(1 \
	#  2 \
	   3)
doesn't work is straightforward interpretation of rc's rules for continued  
lines and comments.  the first \+newline sequence results in the parser  
seeing
	x=(1 #  2 \
	3)
which seems reasonable.  now the question becomes, ``are backslash-newline  
sequences in comments ignored or treated as continuation sequences?''  rc  
currently implements comments by ignoring *everything* until the end of  
line.  the simplicity of this rule argues for not changing it.

two further comments:
	i don't find the ability to insert a comment in the middle of a
		sequence of lines continued with \ important
	i have no idea what td's rc does for this


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: comments, newlines
@ 1992-03-14 19:39 Emin G. Sirer
  1992-03-15 23:31 ` James Matthew Farrow
  0 siblings, 1 reply; 8+ messages in thread
From: Emin G. Sirer @ 1992-03-14 19:39 UTC (permalink / raw)
  To: rc

>From: Dave Mason <dmason@plg.waterloo.edu>
>Subject: RE: comments, newlines 
>Date: Fri, 13 Mar 1992 16:44:35 -0600
>
>> From: John (I've got some bad news for you, sunshine) Mackin
>> Date: Fri, 13 Mar 1992 05:14:22 -0500
>
>> I claim that # should only be seen as a comment introducer if it is
>> preceded by whitespace or at the start of the line.  So if you do
>> 	echo foo#bar
>> you should, in my view, get "foo#bar".  You do in sh.  You don't in rc:
>> Byron thinks # should introduce a comment even if it is in the middle
>> of a word.  I think this is plainly wrong.  Opinions?
>
>Why should it be special? 

	Because almost all the other metacharacters are 'special' in some
way or another. For example, echo f* (or f[a-c]*) will either expand 
(if there are matching files in .) or stay as it is. I think that that 
behaviour is very strange, and even unjustifiable. No part of shell 
behaviour should depend on the environment (i.e. current working directory).
I think csh's the only one that's got it right (gasp).
	Talking about strangeness, how do you explain to someone the bizarre
parenthesis behaviour ? They seem to introduce lists one-minute (a=(a b c))
and seem to mark the clauses to the while and if statements the next.
	'Special' is not the right word. All these characters are already 
special anyway (look in lexer.c; they are called special characters). The
key thing is whether the rules governing their use make sense. I, for one,
find the parenthesis usage very natural. The rule is that they delimit 
lists unless they follow while or if, when they delimit clauses (thus
we don't see code like 'while true echo foo;' I think it is much more 
desirable that we use 'while(true) echo foo'). The rule for '#' should 
be that it introduces comments iff it is preceded by whitespace, else 
it's a regular character.
	And the kind of change we're talking about here only involves a 
trivial change in the lexer.

> What's wrong with
>	echo foo'#'bar

	What's wrong with
		lpr -Gr2 -#3 foo.ps
	? Why doesn't it print anything ? Do you really prefer
		lpr -Gr2 -'#'3 foo.ps
	? Is that better syntax ? Is it more readable ?

>It's not as if octothorpe is exactly the most common character, and I
>think it's actually harder for people to parse by your rules, as they have
>to consider the context of whether it is preceeded by whitespace.

	A lot of the lexical analysis (not parsing) is done in a context
sensitive manner; what's the big deal ?

	I think sh behaviour is more desirable given that the rule is
very simple (both to remember and to implement); so much so that
remembering to escape the number sign is much harder than keeping
the rule in mind (in fact, you don't even have to). Simplicity does
not mean cumbersome notation.

Gun.


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

end of thread, other threads:[~1992-03-15 17:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-03-11  7:19 comments, newlines schwartz
1992-03-11 17:27 haahr
1992-03-12 22:05 ` David J. Fiander
1992-03-13 10:14   ` John Mackin
1992-03-13 22:44     ` Dave Mason
1992-03-14 19:39 Emin G. Sirer
1992-03-15 23:31 ` James Matthew Farrow
1992-03-15 17:54   ` schwartz

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).