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


Groups > comp.lang.forth > #56740

Re: LLVM and Forth

Newsgroups comp.lang.forth
Date 2017-04-05 00:00 -0700
References (2 earlier) <qOKdneQNfs-vmH_FnZ2dnUU7-UednZ2d@supernews.com> <72a319fa-8035-4a17-a5a2-2b2884a57b15@googlegroups.com> <oc07kj$il8$1@cherry.spenarnc.xs4all.nl> <c7b0253d-7f8d-4eb7-a6f3-2a9b43f66509@googlegroups.com> <20170405004435.4706b792@_>
Message-ID <cdc8055a-160a-46e4-a466-e289edfe1e45@googlegroups.com> (permalink)
Subject Re: LLVM and Forth
From minforth@arcor.de

Show all headers | View raw


Am Mittwoch, 5. April 2017 06:43:37 UTC+2 schrieb Rod Pemberton:
> On Tue, 4 Apr 2017 17:57:52 -0700 (PDT)
> krishna.myneni@ccreweb.org wrote:
> 
> > On Tuesday, April 4, 2017 at 8:37:46 AM UTC-5, Albert van der Horst
> > wrote:
> > > In article <72a319fa-8035-4a17-a5a2-2b2884a57b15@googlegroups.com>,
> > >  <krishna.myneni@ccreweb.org> wrote:  
> 
> > > Having a special action for 1+ is silly anyway.
> > > The ++ operator is a remnance of the PDP11 era, there is not a shred
> > > of a reason to use it in output for a translator. ...  
> > 
> > Isn't there an INC operation in x86?
> > 
> 
> 16-bit.  Yes.
> 32-bit.  Yes.
> 64-bit.  No.  (It was reassigned for the REX prefix.)
> 
> You can see this on Sandpile.org's "1 byte opcodes" page:
> http://www.sandpile.org/x86/opc_1.htm
> 
> Sandpile.org
> "The world's leading source for technical x86 processor information."
> http://www.sandpile.org/
> 
> > >    Everyone using ++ or -- in the output of a Forth to C translator
> > >    is an idiot.
> > >   
> > 
> > I would think the criteria for being an idiot is more general than
> > that, at least with present day C compilers.
> > 
> 
> Today, adding one or subtracting one optimizes just as well, but isn't
> as compact to code.
> 
> There is nothing wrong with ++ or -- , AS LONG AS you follow the ANSI C
> rules for using them.   Of course, almost no one knows or remembers or
> uses these rules ...
> 
> ANSI C introduced rules for their use with the "sequence points"
> concept of ANSI C.  This resulted in the pre- and post-decrement or
> pre- and post-increment operations to sometimes erroneously affect the
> result of a computed value when the sequence is optimized or compiled.
> I.e., the order of operations for ANSI C was changed and is not
> guaranteed to be identical to that of K&R C or earlier.
> 
> The ANSI C rules say that you must separate out the usage or pre- and
> post-decrement and pre- and post-increment from other C code.  These
> rules carry over into ISO C, even if not stated.
> 
> This, for ANSI C compliance,
>     v = ++v + 2;
> 
> should be rewritten as this:
>     ++v;
>     v = v + 2:
> 
> 
> This, for ANSI C compliance,
>     v = v++ + 2;
> 
> should be rewritten as this:
>     v = v + 2;
>     v++;
> 
> 
> Of course, these are equivalent:
>     v += 2;
>     v = v + 2;
> 
> 
> The rules are because of situations like this one:
>     v += ++v + 2;     /* coded */
>     v = v + ++v + 2;  /* equivalent */
> 
> If v is 3, is the result 9 or 10?
> 
> Historically, the expected result in C is 10.  I.e., it's equivalent to:
>     ++v;
>     v += v + 2;
> 
> This is because historically pre-increment was supposed to occur first,
> prior to any other operations.  However, ANSI C's sequence points
> concept meant that the operation could occur anywhere prior to the
> semicolon.  It doesn't have to explicitly come first.  I.e., ANSI C
> fiddled with the expected order of operations and completion.
> 
>     v++, v=4, v = 4 + 4 + 2, v=10;   /* pre-ANSI C, v++ occurs first */
>     v = 3 + 3 + 2, v++, v=9;         /* valid for ANSI C ... */
>     v++ (2nd only), v = 3 + 4 + 2, v=9;  /* valid for ANSI C ... */
> 
> It becomes more complicated with sequence points if multiple increments
> or decrements are involved:
> 
>    v = ++v + ++v + 2 ;
> 
> The compiler can apply both pre-increments before, both after, one
> before and one after ... as long as the operations are applied prior to
> the semicolon.
> 
> C also has the rarely used comma ',' operator (sequential expression)
> which allows for multiple statements to occur during the same sequence
> point.  IMO, the sequence point concept is an abomination, but is
> needed for compilers.  And, it is not the only mistake ANSI C committee
> introduced into C.  They spent years correcting a number of other
> serious mistakes.
> 
> 
> Rod Pemberton
> 
> -- 
> All it takes for humanity to conquer the world's toughest problems
> is to hope, to believe, to share, and to do, in cooperation.

So what the heck? Your contrived examples violate basic software engineering rules to not write obscure code.

C and Assembler are well suited to shoot one's own foot. But that does not imply that you have to protect the shootist. Forth is full of unspecified corners as well. No reason for language talibanism.

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


Thread

LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-01 06:36 -0700
  Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-01 14:57 +0000
    Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-01 11:55 -0700
      Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-02 15:24 +0000
  Re: LLVM and Forth rickman <gnuarm@gmail.com> - 2017-04-01 11:21 -0400
    Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-01 11:57 -0700
      Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-02 04:02 -0500
        Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-02 06:35 -0700
          Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-02 14:41 +0000
          Re: LLVM and Forth minforth@arcor.de - 2017-04-03 01:09 -0700
            Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-03 05:32 -0700
              Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-03 13:52 +0000
                Re: LLVM and Forth minforth@arcor.de - 2017-04-03 07:59 -0700
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-03 16:08 +0000
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-03 12:22 -0500
                Re: LLVM and Forth Paul Rubin <no.email@nospam.invalid> - 2017-04-03 20:10 -0700
                Re: LLVM and Forth minforth@arcor.de - 2017-04-03 22:19 -0700
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-04 16:12 +0200
                Re: LLVM and Forth Walter Banks <walter@bytecraft.com> - 2017-04-05 17:27 -0400
            Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-03 14:29 +0000
          Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-03 03:17 -0500
            Re: LLVM and Forth minforth@arcor.de - 2017-04-03 05:04 -0700
            Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-03 12:55 +0000
              Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-03 10:08 -0500
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-03 17:05 +0000
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-04 11:29 -0500
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-04 19:11 +0200
                Re: LLVM and Forth Paul Rubin <no.email@nospam.invalid> - 2017-04-04 21:29 -0700
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-05 15:01 +0000
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-05 18:42 +0100
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-06 04:01 -0500
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-06 18:48 +0000
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-06 18:42 -0700
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-07 04:02 -0500
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-08 21:18 -0700
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-08 22:43 +0000
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-08 20:54 -0700
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-09 14:53 +0000
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-10 00:38 +0000
                Re: LLVM and Forth James Kuyper <jameskuyper@verizon.net> - 2017-04-09 22:46 -0400
                Re: LLVM and Forth Robert Wessel <robertwessel2@yahoo.com> - 2017-04-09 22:27 -0500
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-10 12:36 +0000
                Re: LLVM and Forth Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-10 14:09 +0100
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-10 13:07 +0000
                Re: LLVM and Forth Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-10 16:18 +0100
                Re: LLVM and Forth "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-10 11:51 -0400
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-12 21:32 +0000
                Re: LLVM and Forth "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-12 18:29 -0400
                Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-12 15:29 -0700
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-13 02:55 +0200
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-10 18:38 -0700
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-10 11:54 -0500
                Re: LLVM and Forth Paul Rubin <no.email@nospam.invalid> - 2017-04-10 10:17 -0700
              Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-03 17:02 +0100
              Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-03 10:03 -0700
            Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-04 03:25 -0700
              Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-04 11:24 +0000
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-04 04:55 -0700
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-04 12:28 +0000
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-04 16:16 +0000
              Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-04 15:38 +0200
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-04 16:06 +0200
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-04 17:57 -0700
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-05 00:44 -0400
                Re: LLVM and Forth minforth@arcor.de - 2017-04-05 00:00 -0700
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-05 08:47 -0700
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-05 11:04 -0500
                Re: LLVM and Forth john <anon@example.com> - 2017-04-05 18:04 +0100
                Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-05 13:04 -0700
                Re: LLVM and Forth Paul Rubin <no.email@nospam.invalid> - 2017-04-05 18:20 -0700
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-05 20:14 -0700
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-06 12:33 +0000
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-06 10:49 -0700
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 18:55 +0100
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-06 20:41 +0000
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 21:47 +0100
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 21:56 +0100
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-06 23:59 -0400
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-06 17:10 -0700
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-07 03:33 -0400
                Re: LLVM and Forth Spiros Bousbouras <spibou@gmail.com> - 2017-04-08 22:48 +0000
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-09 15:06 -0400
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-08 22:45 -0700
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-09 14:27 +0000
                Re: LLVM and Forth Joel Rees <joel.rees@gmail.com> - 2017-04-09 21:26 -0700
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-09 13:35 -0400
                Re: LLVM and Forth Paul Rubin <no.email@nospam.invalid> - 2017-04-09 14:07 -0700
                Re: LLVM and Forth minforth@arcor.de - 2017-04-05 12:16 -0700
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-05 20:27 -0700
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-06 05:24 -0400
                Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-06 03:26 -0700
                Re: LLVM and Forth minforth@arcor.de - 2017-04-06 04:05 -0700
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-06 06:50 -0500
                Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-06 05:23 -0400
                Re: LLVM and Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-06 04:44 -0500
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 10:57 +0100
                Re: LLVM and Forth peter.m.falth@gmail.com - 2017-04-05 05:29 -0700
                Re: LLVM and Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-14 02:04 +0000
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-15 14:03 +0200
                Re: LLVM and Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 00:44 +0000
                Re: LLVM and Forth alex@rivadpm.com - 2017-04-16 05:53 -0700
                Re: LLVM and Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-16 15:43 +0000
                Re: LLVM and Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 22:27 +0000
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-18 02:45 +0200
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-18 18:26 +0100
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 19:51 +0200
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-20 19:08 +0100
                Re: LLVM and Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 20:42 +0200
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-20 20:29 +0100
                Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-20 20:48 +0100
                Re: LLVM and Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 11:49 +0000
          Re: LLVM and Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-03 20:39 -0400
  Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-02 21:15 +0100
    Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-02 15:18 -0700
      Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-03 13:07 +0100
        Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-03 09:45 -0700
          Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-03 22:52 +0100
            Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-03 15:25 -0700
              Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 09:35 +0100
      Re: LLVM and Forth antispam@math.uni.wroc.pl - 2017-04-06 01:36 +0000
        Re: LLVM and Forth minforth@arcor.de - 2017-04-05 22:00 -0700
          Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 09:52 +0100
        Re: LLVM and Forth hughaguilar96@gmail.com - 2017-04-06 20:15 -0700
    Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-03 05:20 -0700
      Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-03 17:11 +0100
  Re: LLVM and Forth Alex <alex@rivadpm.com> - 2017-04-06 17:43 +0100
    Re: LLVM and Forth krishna.myneni@ccreweb.org - 2017-04-06 10:53 -0700

csiph-web