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


Groups > comp.lang.forth > #45489 > unrolled thread

How do you remember the stack?

Started bylaheadle@gmail.com
First post2016-02-12 13:57 -0800
Last post2016-02-22 01:46 -0800
Articles 20 on this page of 115 — 26 participants

Back to article view | Back to comp.lang.forth


Contents

  How do you remember the stack? laheadle@gmail.com - 2016-02-12 13:57 -0800
    Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-12 14:08 -0800
      Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-16 13:35 +1100
        Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-15 19:28 -0800
        Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-15 19:54 -0800
        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 07:28 +0000
          Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-15 22:03 -1000
            Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 13:30 +0000
              Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-16 08:20 -1000
                Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-16 20:48 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-17 15:42 +0000
            Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-18 18:48 +1100
              Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-18 12:27 -0800
                Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-18 14:53 -0800
                  Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-18 15:18 -0800
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-21 13:32 +1100
                  Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-20 20:57 -0800
                    Re: How do you remember the stack? Ron Aaron <rambamist@gmail.com> - 2016-02-21 07:23 +0200
                      Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-21 08:54 -0800
                  Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-21 22:05 -0800
                  Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-22 16:20 +0100
                    Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-22 09:47 -0600
                    Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-23 16:51 -0800
                      Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-28 15:22 +1100
                        Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-27 21:30 -0800
                          Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-27 21:33 -0800
                        Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-27 21:39 -1000
                          Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-29 13:47 +1100
                            Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-28 19:02 -0800
                              Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-28 22:26 -0800
                                Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-28 22:37 -0800
                            Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-28 19:11 -0800
                            Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-29 11:55 -0600
                            Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-29 19:30 -1000
                              Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-03-02 00:49 +1100
                                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-03-01 13:50 -1000
                                Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-03-01 16:49 -0800
                                  Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-03-01 18:04 -0800
                                  Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-03-02 02:53 -0600
                                  Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 09:57 +0000
                                    Re: How do you remember the stack? Pablo Hugo Reda <pabloreda@gmail.com> - 2016-03-02 03:21 -0800
                                      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 11:49 +0000
                                        Re: How do you remember the stack? Pablo Hugo Reda <pabloreda@gmail.com> - 2016-03-02 04:23 -0800
                                    Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-02 18:32 +0000
                                      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 18:41 +0000
                                        Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-02 20:36 +0000
                                        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 07:38 +0000
                                          Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 09:26 +0000
                                            Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 11:15 +0000
                                              Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 15:35 +0000
                                                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 15:56 +0000
                                                  Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 17:04 +0000
                                Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-03-01 19:29 -0800
                        Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-28 18:52 +0000
                        Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-28 13:30 -0800
                        Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-29 07:55 +0100
                          Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-29 19:34 -1000
                            Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-03-01 20:40 -0800
                            Re: How do you remember the stack? Unknown <dog@gmail.com> - 2016-06-02 05:46 +0000
                              Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-06-02 08:48 +0200
                                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-06-02 00:17 -0700
                                Re: How do you remember the stack? Michael Barry <barrym95838@yahoo.com> - 2016-06-02 19:48 -0700
                                  Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-06-02 20:34 -0700
                  Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-02-22 19:23 +0000
                    Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-25 20:31 +1100
                      Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-25 07:44 -0800
                        Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-25 20:22 +0100
                        Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-28 13:43 +1100
                          Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-27 21:43 -1000
                            Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-28 14:53 +0000
                            Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-28 15:27 -0800
                  Re: How do you remember the stack? humptydumpty <ouatubi@gmail.com> - 2016-06-02 02:02 -0700
                  Re: How do you remember the stack? JennyB <jennybrien@googlemail.com> - 2016-06-03 05:57 -0700
        Re: How do you remember the stack? Bernd Paysan <bernd.paysan@gmx.de> - 2016-03-01 16:38 +0000
    Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-12 16:31 -0800
    Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-12 17:31 -0800
    Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-13 08:03 +0100
    Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-13 08:06 +0000
      Re: How do you remember the stack? minforth@arcor.de - 2016-02-13 01:50 -0800
        Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:22 -0800
          Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-13 17:09 +0000
        Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:39 -0800
        Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:42 -0800
        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-13 11:27 +0000
          Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-13 12:33 +0000
            Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 01:05 -0800
        Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-14 19:34 +0000
    Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-13 06:43 -0800
      Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 01:22 -0800
        Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-15 09:48 +0000
        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-15 09:53 +0000
          Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-15 11:26 +0000
            Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 04:53 -0800
              Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-15 17:06 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 14:57 +0000
            Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 14:14 +0000
        Re: How do you remember the stack? Ron Aaron <rambamist@gmail.com> - 2016-02-15 12:31 +0200
        Re: How do you remember the stack? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-02-18 22:53 +0000
    Re: How do you remember the stack? Doug Hoffman <glidedog@gmail.com> - 2016-02-13 10:51 -0500
    Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-14 10:18 +1100
    Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-14 04:21 -0600
    Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-20 14:36 -0800
      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-21 16:35 +0000
        Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-21 18:34 +0000
          Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 09:52 +0000
            Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-22 13:07 +0000
              Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 15:41 +0000
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-22 08:24 -1000
              Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-22 08:21 -1000
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-22 17:51 -0800
                  Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-22 18:15 -0800
                  Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-02-29 06:20 +0000
                  Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-03-02 20:42 +0000
                    Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-06-02 20:13 +0000
    Re: How do you remember the stack? humptydumpty <ouatubi@gmail.com> - 2016-02-22 01:46 -0800

Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →


#45777

FromPablo Hugo Reda <pabloreda@gmail.com>
Date2016-03-02 03:21 -0800
Message-ID<5e37a613-7386-4a6f-b0c5-3d8b98fd12ee@googlegroups.com>
In reply to#45775
> >> Moore has something to say about that:
> >> "Any time a word is used only once you want to question its value."
> >
> >Won't any serious compiler always inline words like that?
> 
> No Forth compiler I know of does that (maybe they are all not
> serious:-).  Why don't they?  Because there is no way for the compiler
> to know how many calls to the word there will be when it compiles a
> call to the word.
> 

my compiler do this, I count the calls and if have 1 call and not have many exits then inline this word.
plus dead code elimination when the caller count 0 to this word

[toc] | [prev] | [next] | [standalone]


#45778

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-03-02 11:49 +0000
Message-ID<2016Mar2.124937@mips.complang.tuwien.ac.at>
In reply to#45777
Pablo Hugo Reda <pabloreda@gmail.com> writes:
>> >> Moore has something to say about that:
>> >> "Any time a word is used only once you want to question its value."
>> >
>> >Won't any serious compiler always inline words like that?
>> 
>> No Forth compiler I know of does that (maybe they are all not
>> serious:-).  Why don't they?  Because there is no way for the compiler
>> to know how many calls to the word there will be when it compiles a
>> call to the word.
>> 
>
>my compiler do this, I count the calls and if have 1 call and not have many exits then inline this word.

So you always inline the first call to a word?  Or do you have a kind
of delayed compilation so that you might see additional calls before
taking the decision?

Torture test:

: foo ( n -- addr )
  a really, really big word
  or maybe one that itself calls a bunch of other words for the first time
;

: bar ( -- x )
  1 foo @ ;

bar .

: flip ( -- addr )
 2 bar @ bar @ bar ;

: flop ( -- )
 5 3 bar @ bar ! ;

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

[toc] | [prev] | [next] | [standalone]


#45779

FromPablo Hugo Reda <pabloreda@gmail.com>
Date2016-03-02 04:23 -0800
Message-ID<0d9be919-bbf1-4aef-aa83-ab4387e40eaa@googlegroups.com>
In reply to#45778
El miércoles, 2 de marzo de 2016, 9:00:42 (UTC-3), Anton Ertl  escribió:
> Pablo Hugo Reda <pabloreda@gmail.com> writes:
> >> >> Moore has something to say about that:
> >> >> "Any time a word is used only once you want to question its value."
> >> >
> >> >Won't any serious compiler always inline words like that?
> >> 
> >> No Forth compiler I know of does that (maybe they are all not
> >> serious:-).  Why don't they?  Because there is no way for the compiler
> >> to know how many calls to the word there will be when it compiles a
> >> call to the word.
> >> 
> >
> >my compiler do this, I count the calls and if have 1 call and not have many exits then inline this word.
> 
> So you always inline the first call to a word?  Or do you have a kind
> of delayed compilation so that you might see additional calls before
> taking the decision?
> 
> Torture test:
> 
> : foo ( n -- addr )
>   a really, really big word
>   or maybe one that itself calls a bunch of other words for the first time
> ;
> 
> : bar ( -- x )
>   1 foo @ ;
> 
> bar .
> 
> : flip ( -- addr )
>  2 bar @ bar @ bar ;
> 
> : flop ( -- )
>  5 3 bar @ bar ! ;
> 
> - anton
> -- 
> M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
>      New standard: http://www.forth200x.org/forth200x.html
>    EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

my forth is not standard is like colorforth, not interactive, first tokenize then compile

[toc] | [prev] | [next] | [standalone]


#45785

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-03-02 18:32 +0000
Message-ID<56d731a7.83533683@news.eternal-september.org>
In reply to#45775
On Wed, 02 Mar 2016 09:57:20 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>Paul Rubin <no.email@nospam.invalid> writes:
>>"HAA" <someone@microsoft.com> writes:
>>> Moore has something to say about that:
>>> "Any time a word is used only once you want to question its value."
>>
>>Won't any serious compiler always inline words like that?
>
>No Forth compiler I know of does that (maybe they are all not
>serious:-).  Why don't they?  Because there is no way for the compiler
>to know how many calls to the word there will be when it compiles a
>call to the word.

iForth, VFX ... and maybe some others.

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#45787

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-03-02 18:41 +0000
Message-ID<2016Mar2.194153@mips.complang.tuwien.ac.at>
In reply to#45785
stephen@mpeforth.com (Stephen Pelc) writes:
>On Wed, 02 Mar 2016 09:57:20 GMT, anton@mips.complang.tuwien.ac.at
>(Anton Ertl) wrote:
>
>>Paul Rubin <no.email@nospam.invalid> writes:
>>>"HAA" <someone@microsoft.com> writes:
>>>> Moore has something to say about that:
>>>> "Any time a word is used only once you want to question its value."
>>>
>>>Won't any serious compiler always inline words like that?
>>
>>No Forth compiler I know of does that (maybe they are all not
>>serious:-).  Why don't they?  Because there is no way for the compiler
>>to know how many calls to the word there will be when it compiles a
>>call to the word.
>
>iForth, VFX ... and maybe some others.

Let's see:

Input program:
: foo 
  if ." bla bla bla" cr 
     ." bla bla bla" cr 
     ." bla bla bla" cr  
     ." bla bla bla" cr  
     ." bla bla bla" cr  
  then ;

: bar dup foo dup ;

So FOO is called only once, in BAR.  It is not inlined by VFX:

VFX Forth for Linux IA32 Version: 4.72 [build 0555]
Including xxx.fs
see bar 
BAR 
( 080C0B60    8D6DFC )                LEA       EBP, [EBP+-04]
( 080C0B63    895D00 )                MOV       [EBP], EBX
( 080C0B66    E845FFFFFF )            CALL      080C0AB0        FOO
( 080C0B6B    8D6DFC )                LEA       EBP, [EBP+-04]
( 080C0B6E    895D00 )                MOV       [EBP], EBX
( 080C0B71    C3 )                    NEXT,
( 18 bytes, 6 instructions )

I also doubt that iForth always inlines used-once words, but I have no
recent iForth to check this.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

[toc] | [prev] | [next] | [standalone]


#45788

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-03-02 20:36 +0000
Message-ID<56d74e6a.90896213@news.eternal-september.org>
In reply to#45787
On Wed, 02 Mar 2016 18:41:53 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>Let's see:
>
>Input program:
>: foo 
>  if ." bla bla bla" cr 
>     ." bla bla bla" cr 
>     ." bla bla bla" cr  
>     ." bla bla bla" cr  
>     ." bla bla bla" cr  
>  then ;

The tokeniser cancels tokenisation for literal strings and a number of
other cases.

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#45796

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-03-03 07:38 +0000
Message-ID<2016Mar3.083831@mips.complang.tuwien.ac.at>
In reply to#45787
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>stephen@mpeforth.com (Stephen Pelc) writes:
>>On Wed, 02 Mar 2016 09:57:20 GMT, anton@mips.complang.tuwien.ac.at
>>(Anton Ertl) wrote:
>>
>>>Paul Rubin <no.email@nospam.invalid> writes:
>>>>"HAA" <someone@microsoft.com> writes:
>>>>> Moore has something to say about that:
>>>>> "Any time a word is used only once you want to question its value."
>>>>
>>>>Won't any serious compiler always inline words like that?
>>>
>>>No Forth compiler I know of does that (maybe they are all not
>>>serious:-).  Why don't they?  Because there is no way for the compiler
>>>to know how many calls to the word there will be when it compiles a
>>>call to the word.
>>
>>iForth, VFX ... and maybe some others.
>
>Let's see:

Ok, second attempt:

: foo
    123456789 + 123456789 * @ 123456789 + 123456789 * @
    123456789 + 123456789 * @ 123456789 + 123456789 * @
    123456789 + 123456789 * @ 123456789 + 123456789 * @
    123456789 + 123456789 * @ 123456789 + 123456789 * @
    123456789 + 123456789 * @ 123456789 + 123456789 * @ ;

: bar 1 foo . ;


VFX Forth for Linux IA32 Version: 4.72 [build 0555]
Including xxx.fs
see bar
BAR 
( 080C0B60    8D6DFC )                LEA       EBP, [EBP+-04]
( 080C0B63    895D00 )                MOV       [EBP], EBX
( 080C0B66    BB01000000 )            MOV       EBX, 00000001
( 080C0B6B    E840FFFFFF )            CALL      080C0AB0        FOO
( 080C0B70    E84F26F9FF )            CALL      080531C4        .
( 080C0B75    C3 )                    NEXT,
( 22 bytes, 6 instructions )

With a line less in FOO, it inlines.  So no, VFX does not always
inline words that are called only once.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

[toc] | [prev] | [next] | [standalone]


#45797

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-03-03 09:26 +0000
Message-ID<56d7ffaa.136272068@news.eternal-september.org>
In reply to#45796
On Thu, 03 Mar 2016 07:38:31 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>>>iForth, VFX ... and maybe some others.
>>
>>Let's see:
>
>Ok, second attempt:
>
>: foo
>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>    123456789 + 123456789 * @ 123456789 + 123456789 * @ ;
>
>: bar 1 foo . ;
>
>
>VFX Forth for Linux IA32 Version: 4.72 [build 0555]
>Including xxx.fs
>see bar
>BAR 
>( 080C0B60    8D6DFC )                LEA       EBP, [EBP+-04]
>( 080C0B63    895D00 )                MOV       [EBP], EBX
>( 080C0B66    BB01000000 )            MOV       EBX, 00000001
>( 080C0B6B    E840FFFFFF )            CALL      080C0AB0        FOO
>( 080C0B70    E84F26F9FF )            CALL      080531C4        .
>( 080C0B75    C3 )                    NEXT,
>( 22 bytes, 6 instructions )
>
>With a line less in FOO, it inlines.  So no, VFX does not always
>inline words that are called only once.

The original discussion was about one-line definitions. VFX tokenises
definitions intelligently. Among the criteria used to discard tokens
are literal strings and binary code size. See the manual, sections
21.7 and 21.8.

: poo  123456789 + 123456789 * @  ;
: foo  poo poo  poo poo  poo poo  poo poo  poo poo  ;
: bar  1 foo . ;

poo is expanded inline, but foo is too big, so it is left alone.

The point about this expansion technique is to deal with phrases
such as:
: st.x  8 + @  ;
: st.y  12 + @ ;
which I still see in current code.

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#45800

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-03-03 11:15 +0000
Message-ID<2016Mar3.121506@mips.complang.tuwien.ac.at>
In reply to#45797
stephen@mpeforth.com (Stephen Pelc) writes:
>On Thu, 03 Mar 2016 07:38:31 GMT, anton@mips.complang.tuwien.ac.at
>(Anton Ertl) wrote:
>
>>>>iForth, VFX ... and maybe some others.
>>>
>>>Let's see:
>>
>>Ok, second attempt:
>>
>>: foo
>>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>>    123456789 + 123456789 * @ 123456789 + 123456789 * @
>>    123456789 + 123456789 * @ 123456789 + 123456789 * @ ;
>>
>>: bar 1 foo . ;
>>
>>
>>VFX Forth for Linux IA32 Version: 4.72 [build 0555]
>>Including xxx.fs
>>see bar
>>BAR 
>>( 080C0B60    8D6DFC )                LEA       EBP, [EBP+-04]
>>( 080C0B63    895D00 )                MOV       [EBP], EBX
>>( 080C0B66    BB01000000 )            MOV       EBX, 00000001
>>( 080C0B6B    E840FFFFFF )            CALL      080C0AB0        FOO
>>( 080C0B70    E84F26F9FF )            CALL      080531C4        .
>>( 080C0B75    C3 )                    NEXT,
>>( 22 bytes, 6 instructions )
>>
>>With a line less in FOO, it inlines.  So no, VFX does not always
>>inline words that are called only once.
>
>The original discussion was about one-line definitions.

Yes, but the question at hand in this subthread was about definitions
that are called only once.  The theory by Paul Rubin was that serious
compilers always inline such definitions.  I wrote that there are no
Forth compilers that do this and gave a reason for that (which does
not apply to Pablo Hugo Reda's non-standard system), you claimed that
iForth and VFX do it, and I demonstrated that VFX doesn't.  Below you
demonstrate that there are even one-line definitions where VFX
doesn't.

>VFX tokenises
>definitions intelligently. Among the criteria used to discard tokens
>are literal strings and binary code size.

But if you knew that the word is called only once, binary code size
would be no reason not to inline.

To the best of my knowlegde, VFX does not use the number of calls as a
criterion for inlining.  That's because in (standard) Forth you don't
know when compiling a call to a word how many calls to this word there
will be.

>: poo  123456789 + 123456789 * @  ;
>: foo  poo poo  poo poo  poo poo  poo poo  poo poo  ;
>: bar  1 foo . ;
>
>poo is expanded inline, but foo is too big, so it is left alone.

A nice demonstration that the non-inlining even happens for one-line
called-once words.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

[toc] | [prev] | [next] | [standalone]


#45805

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-03-03 15:35 +0000
Message-ID<56d85806.158892618@news.eternal-september.org>
In reply to#45800
On Thu, 03 Mar 2016 11:15:06 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>But if you knew that the word is called only once, binary code size
>would be no reason not to inline.

Yes there is. As you correctly point out, at the time of first use of
a word, the compiler does not know how many more compilations will 
occur. It's just a limitation of a single-pass compiler.

However, the word has been compiled once when it was defined - that
permits interactive testing. Inlining still causes space to be used 
However, on multiple compilations, it is possible to save space
because the compiler does not have to maintain the boundary
conditions. This is particularly true of the micro-definitions
used as ad-hoc structure words.

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#45807

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-03-03 15:56 +0000
Message-ID<2016Mar3.165658@mips.complang.tuwien.ac.at>
In reply to#45805
stephen@mpeforth.com (Stephen Pelc) writes:
>On Thu, 03 Mar 2016 11:15:06 GMT, anton@mips.complang.tuwien.ac.at
>(Anton Ertl) wrote:
>>But if you knew that the word is called only once, binary code size
>>would be no reason not to inline.
>
>Yes there is. As you correctly point out, at the time of first use of
>a word, the compiler does not know how many more compilations will 
>occur. It's just a limitation of a single-pass compiler.
>
>However, the word has been compiled once when it was defined - that
>permits interactive testing. Inlining still causes space to be used

Well, if you knew that the word is called only once, you would also
know that it is not called interactively, eliminating the need for
creating a standalone version of it.

>However, on multiple compilations, it is possible to save space
>because the compiler does not have to maintain the boundary
>conditions.

Using call counts (including calls from the text interpreter) from one
run for guiding the inlining decisions of the next run is an
interesting idea.  Even if the program changes between the runs, the
possible damage is limited if you limit the amount of inlining to the
amount of calls in the last run.

But in any case, no (standard) Forth compiler I know of uses this
technique yet, and AFAIK call counts don't play any role in inlining
decisions in (standard) Forth compilers yet.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

[toc] | [prev] | [next] | [standalone]


#45808

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-03-03 17:04 +0000
Message-ID<56d86e7b.164641661@news.eternal-september.org>
In reply to#45807
On Thu, 03 Mar 2016 15:56:58 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>But in any case, no (standard) Forth compiler I know of uses this
>technique yet, and AFAIK call counts don't play any role in inlining
>decisions in (standard) Forth compilers yet.

I'm sure that you are always right about everything.

Stephen


-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#45770

FromWhammo <sidciavic@gmail.com>
Date2016-03-01 19:29 -0800
Message-ID<c3a11f21-988f-4225-a1dd-f906bb287339@googlegroups.com>
In reply to#45757
> Whammo had no basis for factoring.  He factored until there was
> nothing left - exactly what Wong said shouldn't be done.  Six of his
> seven new words are used only once.  Moore has something to
> say about that:
> 
> "Any time a word is used only once you want to question its value."

  Only for the record, I have never posted code to this group.
My sole experience with programming Forth is with DurexForth for the Commodore 64 of which I have been a (very) minor contributor but have done serious coding.
 Here is an example of the PPP frame check sequence table that prints to the screen for validation.

8408 constant p

: fori 8 0 do 
dup 1 rshift swap 
1 and if p xor 
      then loop ;

: aie and 0= if 30 emit then ;

: l0 dup f000 aie
     dup ff00 aie 
     dup fff0 aie u. ;
      
: forb c000 100 0 do 

i fori over ! cell+ 

loop drop ;

[toc] | [prev] | [next] | [standalone]


#45736

FromAlbert van der Horst <albert@spenarnc.xs4all.nl>
Date2016-02-28 18:52 +0000
Message-ID<56d34208$0$24049$e4fe514c@news.xs4all.nl>
In reply to#45728
"HAA" <someone@microsoft.com> writes:

>Whammo wrote:
>> On Monday, February 22, 2016 at 7:20:58 AM UTC-8, Lars Brinkhoff wrote:
>> > "HAA" <someone@microsoft.com> writes:
>> > > OFW practice what they preach:
>> > >
>> > > : do-buffer  ( apf -- adr )
>> > >    dup >user @  if          ( apf )
>> > >       >user @                 ( adr )
>> > >    else                           ( apf )
>> > >       dup /user# + @      ( apf size )
>> > >       dup alloc-mem       ( apf size adr )
>> > >       dup rot erase         ( apf adr )
>> > >       dup rot >user !       ( adr )
>> > >    then
>> > > ;
>> > >
>> > > Which code would you prefer to work with - with or without the stack
>> > > comments?
>> >
>> > I like short words, so I might have written it something like this.
>> >
>> > : alloc-erased ( size -- adr ) dup >r alloc-mem  dup r> erase ;
>> >
>> > : /user ( apf -- size ) /user# + @ ;
>> > : user@ ( apf -- adr ) >user @ ;
>> > : user! ( adr apf -- ) >user ! ;
>> > : alloc-user ( apf -- adr ) /user alloc-erased ;
>> > : +user ( apf -- ) dup alloc-user swap user! ;
>> > : ?+user ( apf -- apf ) dup user@ 0= if dup +user then ;
>> >
>> > : do-buffer ( apf -- adr ) ?+user user@ ;
>>
>>  Brilliant! Anyone could sort out this code.

>You have 7 new words and stack effects to remember.
>How is this brilliant?

Compared to the original code the first 4 are for me trivial to
remember. If I had a clue what do-buffer is supposed to do,
this may be true for the remaining 3 also.

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#45739

FromWhammo <sidciavic@gmail.com>
Date2016-02-28 13:30 -0800
Message-ID<615ee38c-0054-4bc6-8080-589587048b2c@googlegroups.com>
In reply to#45728
> >  Brilliant! Anyone could sort out this code.
> 
> You have 7 new words and stack effects to remember.
> How is this brilliant?

 Because once you understand the problem, and have designed a solution,
the coding is trivial.
  

[toc] | [prev] | [next] | [standalone]


#45748

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-02-29 07:55 +0100
Message-ID<86a8mkovib.fsf@molnjunk.nocrew.org>
In reply to#45728
"HAA" <someone@microsoft.com> writes:
> You have 7 new words and stack effects to remember.
> How is this brilliant?

I'm certainly not saying this is brilliant.  Maybe the opposite!

Those that are brilliant experienced Forth programmers can probably get
away with writing long complex definitions.  Kudos to them!

But I'm not brilliant.  My short-term memory can't handle that many
items.  Too much stack juggling confuses me.  Writing a metacompiler
took me tree attempts.

So when I'm writing a definition and I'm losing track its internal stack
state, I break it up.  When I can glance at a definition and immediately
see that it's "obviously correct", then I'm happy.

But I'm not advocating this for everyone.  By all means, use whatever
style you're comfortable with.

[toc] | [prev] | [next] | [standalone]


#45755

From"Elizabeth D. Rather" <erather@forth.com>
Date2016-02-29 19:34 -1000
Message-ID<cYudnRwbXq55tEjLnZ2dnUU7-bPNnZ2d@supernews.com>
In reply to#45748
On 2/28/16 8:55 PM, Lars Brinkhoff wrote:
> "HAA" <someone@microsoft.com> writes:
>> You have 7 new words and stack effects to remember.
>> How is this brilliant?
>
> I'm certainly not saying this is brilliant.  Maybe the opposite!
>
> Those that are brilliant experienced Forth programmers can probably get
> away with writing long complex definitions.  Kudos to them!

The most brilliant and experienced Forth programmers I know write short, 
simple, well-documented definitions.

> But I'm not brilliant.  My short-term memory can't handle that many
> items.  Too much stack juggling confuses me.  Writing a metacompiler
> took me tree attempts.
>
> So when I'm writing a definition and I'm losing track its internal stack
> state, I break it up.  When I can glance at a definition and immediately
> see that it's "obviously correct", then I'm happy.
>
> But I'm not advocating this for everyone.  By all means, use whatever
> style you're comfortable with.

I'm with you, Lars!

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

[toc] | [prev] | [next] | [standalone]


#45771

Fromhughaguilar96@gmail.com
Date2016-03-01 20:40 -0800
Message-ID<61897451-e5e0-48dc-811b-7986e7b3dd11@googlegroups.com>
In reply to#45755
On Monday, February 29, 2016 at 10:34:29 PM UTC-7, Elizabeth D. Rather wrote:
> On 2/28/16 8:55 PM, Lars Brinkhoff wrote:
> > "HAA" <someone@microsoft.com> writes:
> >> You have 7 new words and stack effects to remember.
> >> How is this brilliant?
> >
> > I'm certainly not saying this is brilliant.  Maybe the opposite!
> >
> > Those that are brilliant experienced Forth programmers can probably get
> > away with writing long complex definitions.  Kudos to them!
> 
> The most brilliant and experienced Forth programmers I know write short, 
> simple, well-documented definitions.

You also said that you hob nob with multiple Nobel Peace Prize winners --- if you know so many brilliant and experienced Forth programmers, why is SwiftForth so grossly inefficient and bereft of features?

I agree that writing short, simple and well-documented definitions is good --- but even good advice turns to crap when it comes out of your mouth.

Actually, everybody agrees that writing short, simple and well-documented definitions is good --- nobody is arguing for long, complicated and badly documented definitions --- this is like how politicians argue in favor of patriotism and freedom and apple pie...

I think that everybody should shut the hell up --- try writing some Forth programs --- you might learn something if you actually put into practice all of this good advice that flows so freely on comp.lang.forth..

[toc] | [prev] | [next] | [standalone]


#47715

FromUnknown <dog@gmail.com>
Date2016-06-02 05:46 +0000
Message-ID<pan.2016.06.02.15.48.48@gmail.com>
In reply to#45755
On Mon, 29 Feb 2016 19:34:35 -1000, Elizabeth D. Rather wrote:

> On 2/28/16 8:55 PM, Lars Brinkhoff wrote:
>> "HAA" <someone@microsoft.com> writes:
>>> You have 7 new words and stack effects to remember. How is this
>>> brilliant?
>>
>> I'm certainly not saying this is brilliant.  Maybe the opposite!
>>
>> Those that are brilliant experienced Forth programmers can probably get
>> away with writing long complex definitions.  Kudos to them!
> 
> The most brilliant and experienced Forth programmers I know write short,
> simple, well-documented definitions.
> 
>> But I'm not brilliant.  My short-term memory can't handle that many
>> items.  Too much stack juggling confuses me.  Writing a metacompiler
>> took me tree attempts.
>>
>> So when I'm writing a definition and I'm losing track its internal
>> stack state, I break it up.  When I can glance at a definition and
>> immediately see that it's "obviously correct", then I'm happy.
>>
>> But I'm not advocating this for everyone.  By all means, use whatever
>> style you're comfortable with.
> 
The secret is in your phrase "GLANCE AT".
Menu-based means you don't need to remember, you just recognise.
"Well commented" tries to use this fact that humans are VISUAL.
[dogs and ants are said to work via smells]
COLOR potentially adds an extra dimension to the menu effect, in a
very compact efficient way.

The fact that CM's colorForth didn't 'catch-on' is perhaps due to
today's F/B, twitter kiddies being conditioned & wanting to imitate
TV talk-show personalities?

[toc] | [prev] | [next] | [standalone]


#47720

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-06-02 08:48 +0200
Message-ID<86bn3kcchu.fsf@molnjunk.nocrew.org>
In reply to#47715
Unknown:
> "Well commented" tries to use this fact that humans are VISUAL.
> [dogs and ants are said to work via smells]

Supposedly, some programmers are sensitive to code smells.  Maybe some
kind of nose attachment would be a good user interface.

[toc] | [prev] | [next] | [standalone]


Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →

Back to top | Article view | comp.lang.forth


csiph-web