Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #28633

Re: Forth reinvention

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From "Rod Pemberton" <dont_use_email@xnohavenotit.cnm>
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 <op.xbly06p05zc71u@localhost> (permalink)
References <b5ec955a-146f-41ea-a227-22e4224cab49@googlegroups.com> <op.xbkrqu0h5zc71u@localhost> <le553r$d32$1@dont-email.me> <op.xblmpdha5zc71u@localhost> <le62sf$csc$1@dont-email.me>
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

Show key headers only | View raw


On Thu, 20 Feb 2014 18:25:04 -0500, Alex McDonald <blog@rivadpm.com> wrote:
> on 20/02/2014 21:16:16, "Rod Pemberton" wrote:
>> On Thu, 20 Feb 2014 09:56:59 -0500, Alex McDonald <blog@rivadpm.com>

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

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Forth reinvention dambere@web.de - 2014-02-20 01:19 -0800
  Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-20 05:07 -0500
    Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-20 14:56 +0000
      Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-20 16:16 -0500
        Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-20 23:25 +0000
          Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-20 20:42 -0500
            Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-21 12:41 +0000
  Re: Forth reinvention Hans Bezemer <the.beez.speaks@gmail.com> - 2014-02-20 11:18 +0100
    Re: Forth reinvention dambere@web.de - 2014-02-20 02:36 -0800
      Re: Forth reinvention Hans Bezemer <the.beez.speaks@gmail.com> - 2014-02-20 17:35 +0100
        Re: Forth reinvention dambere@web.de - 2014-02-20 11:34 -0800
          Re: Forth reinvention "Elizabeth D. Rather" <erather@forth.com> - 2014-02-20 09:53 -1000
          Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-02-20 12:23 -0800
            Re: Forth reinvention dambere@web.de - 2014-02-20 14:00 -0800
              Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-02-20 14:23 -0800
                Re: Forth reinvention dambere@web.de - 2014-02-22 02:21 -0800
                Re: Forth reinvention AKK <akk@nospam.org> - 2014-02-22 12:02 +0100
              Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-21 04:38 -0600
          Re: Forth reinvention Mark Wills <markrobertwills@yahoo.co.uk> - 2014-02-20 12:35 -0800
            Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-02-20 13:38 -0800
  Re: Forth reinvention m.a.m.hendrix@tue.nl - 2014-02-20 03:59 -0800
    Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-20 15:11 +0000
      Re: Forth reinvention m.a.m.hendrix@tue.nl - 2014-02-20 07:41 -0800
  Re: Forth reinvention Richard Owlett <rowlett@pcnetinc.com> - 2014-02-20 06:38 -0600
    Re: Forth reinvention dambere@web.de - 2014-02-20 12:03 -0800
  Re: Forth reinvention Julian Fondren <julian.fondren@gmail.com> - 2014-02-20 07:08 -0800
  Re: Forth reinvention "Elizabeth D. Rather" <erather@forth.com> - 2014-02-20 09:37 -1000
    Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-20 20:50 +0000
      Re: Forth reinvention "Elizabeth D. Rather" <erather@forth.com> - 2014-02-20 15:39 -1000
        Re: Forth reinvention albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-02-21 10:50 +0000
        Re: Forth reinvention Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2014-02-21 11:10 +0000
          Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-21 13:50 +0000
        Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-21 05:46 -0600
          Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-21 12:55 +0000
          Re: Forth reinvention anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-02-21 15:11 +0000
            Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-22 09:23 -0600
        Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-21 12:38 +0000
        Re: Forth reinvention anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-02-22 13:29 +0000
          Re: Forth reinvention "Elizabeth D. Rather" <erather@forth.com> - 2014-02-22 07:52 -1000
            Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-22 19:06 +0000
            Re: Forth reinvention anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-02-23 13:40 +0000
    Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-20 20:40 -0500
      Re: Forth reinvention "Elizabeth D. Rather" <erather@forth.com> - 2014-02-20 18:43 -1000
        Re: Forth reinvention Hans Bezemer <the.beez.speaks@gmail.com> - 2014-02-21 13:16 +0100
      Re: Forth reinvention stephenXXX@mpeforth.com (Stephen Pelc) - 2014-02-21 10:49 +0000
    Re: Forth reinvention anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-02-21 14:50 +0000
      Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-21 16:28 +0000
        Re: Forth reinvention anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-02-22 12:54 +0000
          Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-22 10:27 -0500
          Re: Forth reinvention "Alex McDonald" <blog@rivadpm.com> - 2014-02-22 17:49 +0000
      Re: Forth reinvention Bernd Paysan <bernd.paysan@gmx.de> - 2014-02-21 20:51 +0100
        Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-22 09:39 -0600
          Re: Forth reinvention Bernd Paysan <bernd.paysan@gmx.de> - 2014-02-23 02:40 +0100
            Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-02-22 19:24 -0800
              Re: Forth reinvention Bernd Paysan <bernd.paysan@gmx.de> - 2014-02-23 22:48 +0100
            Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-23 04:39 -0600
              Re: Forth reinvention Bernd Paysan <bernd.paysan@gmx.de> - 2014-02-23 22:46 +0100
                Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-02-23 14:26 -0800
                Re: Forth reinvention Bernd Paysan <bernd.paysan@gmx.de> - 2014-02-24 02:44 +0100
                Re: Forth reinvention Spam@ControlQ.com - 2014-03-03 12:43 -0500
                Re: Forth reinvention Paul Rubin <no.email@nospam.invalid> - 2014-03-03 10:06 -0800
                Re: Forth reinvention Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-24 03:59 -0600
  Re: Forth reinvention mike73900@gmail.com - 2014-03-03 14:04 -0800
    Re: Forth reinvention mhx@iae.nl - 2014-03-05 06:59 -0800
      Re: Forth reinvention Matthias Koch <matthias.koch@hot.uni-hannover.de> - 2014-03-05 16:33 +0100
      Re: Forth reinvention Mark Wills <markwills1970@gmail.com> - 2014-03-05 09:08 -0800
        Re: Forth reinvention mhx@iae.nl - 2014-03-05 10:47 -0800
  Re: Forth reinvention AKK <akk@nospam.org> - 2014-03-07 07:30 +0100
    Re: Forth reinvention Lars Brinkhoff <lars.spam@nocrew.org> - 2014-03-07 07:55 +0100
    Re: Forth reinvention albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-07 09:29 +0000
      Re: Forth reinvention AKK <akk@nospam.org> - 2014-03-07 12:04 +0100
      Re: Forth reinvention "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-07 17:03 -0500
        Re: Forth reinvention Mark Wills <markwills1970@gmail.com> - 2014-03-08 05:31 -0800

csiph-web