Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Forth reinvention Date: Thu, 20 Feb 2014 20:42:32 -0500 Organization: Aioe.org NNTP Server Lines: 133 Message-ID: References: NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:28633 On Thu, 20 Feb 2014 18:25:04 -0500, Alex McDonald wrote: > on 20/02/2014 21:16:16, "Rod Pemberton" wrote: >> On Thu, 20 Feb 2014 09:56:59 -0500, Alex McDonald >> Of course, in C the syntax uses braces, if the block is more >> than just one statement: >> >> [snip] > > This is legal C that has no blocks. > > if ( x==y ) then a=1; else b=1; > Sorry, it's not legal C. C has no "then" ... :-) Did you catch that after you posted and cringe? ;-) So, your example, fixed: if ( x==y ) a=1; else b=1; That example does too have blocks. They just don't need to be marked. I mentioned that above: RP> "if the block is more than just one statement" Those blocks are only one statement. The fixed example is the same as this: if(x==y) a=1; else b=1; which is the same as this: /* braces optional */ /* indicates location of the block */ if(x==y) { a=1; } else { b=1; } You only need the braces for more than one statement per block: /* braces required */ if(x==y) { a=1; c=2; } else { b=1; d=3; } Of course, most "skilled" C programmers prefer to format C (oddly) like so: /* with spaces, offset braces */ if ( x == y ) { a = 1; c = 2; } else { b = 1; d = 3; } The problem with that is it leads to misaligned braces and/or indentation over time. And, of course, in C, you can write that without any formatting or spacing at all: if(x==y){a=1;c=2;}else{b=1;d=3;} But, you (generally) need a space here, although it's not required: if(x==y)a=1;else b=1; That space depends on the parsing implementation. Most C parsers need it. Otherwise, IIRC, the only place C requires a space is for "long long". Other C types are just one word, not including sign: "int" "short" "long" "char". >> These locations >> correspond to where they are used in Forth control-flow words too. >> Some Forths use BRANCH and 0BRANCH or ?BRANCH to place these branches. >> The keywords in C mark some of other locations just as in Forth. The >> rest are escape control-flow words like UNLOOP and EXIT in Forth or >> 'break', 'continue' or 'goto' in C. >> >> Block >> http://en.wikipedia.org/wiki/Block_(programming) >> >> Control-flow >> http://en.wikipedia.org/wiki/Control_flow > > Control flow doesn't make it a block structured language (and the > articles you provide make that clear). > I don't know what you're replying to here. You seem to be conflating control flow with block structured languages. Then, you're ascribing it to me ... > { int a; a=1; f(a) } { int b; b=2; f(b) } > > and not a control flow in sight. > C has blocks. Blocks aren't marked by keywords. They're marked by braces. C's not a block structured language. Forth has blocks. Blocks are marked by keywords. Forth is a block structured language. Those keywords correspond to control flow. Even if we throw C's procedures and Forth's colon-definition into the mix, I don't see that anything changes. Those mark blocks too. Rod Pemberton