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


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

Is there a better way?

Started byMark Wills <forthfreak@gmail.com>
First post2012-10-31 04:58 -0700
Last post2012-11-02 13:13 -0400
Articles 20 on this page of 169 — 25 participants

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


Contents

  Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 04:58 -0700
    Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 05:22 -0700
      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 05:44 -0700
        Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 11:29 -0400
          Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 11:40 -0400
            Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 08:45 -0700
              Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-02 04:48 -0400
            Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-10-31 21:42 -0400
              Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 19:19 -0700
                Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 13:06 -0400
                  Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-02 12:18 -0500
                    Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 14:34 -0400
                      Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 11:39 -0700
                        Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 14:43 -0400
                          Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 02:36 -0600
                            Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-04 14:18 -0500
                      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 14:38 -0700
                        Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 03:01 -0600
                          Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 03:54 -0800
                            Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 07:59 -0600
                            Re: Is there a better way? Elizabeth D Rather <erather@forth.com> - 2012-11-04 08:34 -1000
                              Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-04 15:22 -0800
                                Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-05 02:39 -0800
                                  Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-05 14:01 -0500
                                    Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-05 10:39 -1000
                                      Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-05 21:07 -0800
                                        Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-06 20:57 -0500
                                          Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-06 21:43 -0800
                                            Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-07 03:52 -0800
                                            Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-07 19:55 -0500
                                              Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-07 20:46 -1000
                                                Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-08 10:39 +0000
                                              Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-12 03:48 -0600
                                                Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 07:57 -1000
                                                  Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-12 19:50 -0500
                                                Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-12 19:49 -0500
                                                  Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 15:00 -1000
                                                    Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 00:50 -0800
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 00:58 -0800
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 23:17 -1000
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-13 13:44 +0000
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-13 13:53 +0000
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-13 06:39 -0800
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-13 18:02 +0000
                                                            Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-13 12:10 -0800
                                                              Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-15 16:59 +0000
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 07:55 -0800
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:34 -0500
                                                            Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-14 05:01 -0800
                                                              Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-14 16:11 +0000
                                                              Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-14 09:36 -1000
                                                                Re: Words consuming arguments, was [Re: Is there a better way?] humptydumpty <ouatubi@gmail.com> - 2012-11-14 12:19 -0800
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-13 10:20 -0600
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] Brad Eckert <hwfwguy@gmail.com> - 2012-11-13 08:50 -0800
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:42 -0500
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-14 14:14 +0000
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-14 15:28 +0000
                                                            Re: Words consuming arguments, was [Re: Is there a better way?] Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-14 17:54 +0100
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-14 15:01 -0800
                                                            Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-15 00:08 -0800
                                                              Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-15 15:18 +0000
                                                                Re: Strings (was: Words consuming arguments) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-15 16:36 +0000
                                                                Re: Strings (was: Words consuming arguments) "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 18:35 -0500
                                                                  Re: Strings (was: Words consuming arguments) stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-16 00:36 +0000
                                                                    Re: Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-16 17:42 +0000
                                                                  Re: Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-16 17:55 +0000
                                                              Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-17 04:18 -0800
                                                                Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-17 04:56 -0800
                                                                  Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-17 07:24 -1000
                                                                    Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-19 15:58 -0800
                                                                      Re: Words consuming arguments, was [Re: Is there a better way?] Brad Eckert <hwfwguy@gmail.com> - 2012-11-20 08:17 -0800
                                                    Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:30 -0500
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-14 09:06 -1000
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 06:18 -0500
                                                  Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-13 04:26 -0600
                                                    Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:29 -0500
                                                      Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-14 06:03 -0600
                                                        Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 07:15 -0500
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-15 11:51 -0600
                                                            Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 18:44 -0500
                                                              Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-16 03:50 -0600
                                                          Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-15 08:09 -1000
                                          Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-06 21:19 -1000
                                            Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-07 20:00 -0500
                                              Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-08 10:49 +0000
                                          Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-07 14:01 +0000
                        Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 11:07 +0100
                          Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 11:36 +0100
                            Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 03:48 -0800
                              Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 13:31 +0100
                              Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-11-04 13:29 +0100
                                Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 04:42 -0800
                      Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 02:38 -0600
      Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 10:20 -0400
    Re: Is there a better way? humptydumpty <ouatubi@gmail.com> - 2012-10-31 05:53 -0700
    Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 09:23 -0400
      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 06:41 -0700
        Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-10-31 11:46 -0500
          Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:27 -0700
            Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 14:32 -0700
              Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-10-31 16:15 -0700
            Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-10-31 22:49 +0100
            Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-10-31 17:13 -0500
              Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 23:39 -0700
                Re: Is there a better way? "Elizabeth D. Rather" <erather@forth.com> - 2012-10-31 20:58 -1000
                Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 02:04 -0700
            Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 19:13 -0400
            Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-02 17:31 +0000
              Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 10:37 -0700
                Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-02 18:12 +0000
                  Re: Is there a better way? "Elizabeth D. Rather" <erather@forth.com> - 2012-11-02 08:29 -1000
                    Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-05 14:53 +0000
                  Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 11:30 -0700
                    Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 00:15 +0100
                      Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 19:21 -0400
                        Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 00:42 +0100
                          Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 20:21 -0400
                            Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 01:44 +0100
                              Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-03 12:12 -0400
                                Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 18:24 +0100
                                  Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-03 14:00 -0400
                                Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-03 10:29 -0700
                      Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 18:42 -0700
                    Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-05 11:45 +0000
          Re: Is there a better way? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-01 21:00 +0000
    Re: Is there a better way? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-10-31 15:26 +0000
      Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 12:22 -0400
        Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 15:07 -0700
          Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 19:16 -0400
            Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 06:31 -0700
              Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 10:34 -0400
                Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 10:48 -0400
                  Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:55 -0700
                Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:49 -0700
                  Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 12:46 -0400
              Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-01 09:37 -0500
              Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-01 07:41 -0700
                Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:52 -0700
                  Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-01 12:18 -0500
                    Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 19:38 -0700
                      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 02:29 -0700
                        Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-04 21:48 -0800
                          Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-05 02:44 -0800
              Re: Is there a better way? Graham NEWS <gray@forthman.plus.com> - 2012-11-01 15:52 +0000
            Re: Is there a better way? Josh Grams <josh@qualdan.com> - 2012-11-03 16:38 +0000
      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:26 -0700
        Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-01 13:42 -0400
    Re: Is there a better way? Graham <""gray\"@forthman@plus.com"> - 2012-10-31 17:05 +0000
      Re: Is there a better way? Peter Fälth <peter.falth@tin.it> - 2012-10-31 12:07 -0700
        Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 12:12 -0700
          Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:17 -0700
      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:21 -0700
        Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 14:50 -0700
          Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 14:51 -0700
            Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 14:57 -0700
              Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-10-31 23:47 +0100
                Re: Is there a better way? mhx@iae.nl (Marcel Hendrix) - 2012-11-01 21:28 +0200
          Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 15:11 -0700
            Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 15:44 -0700
              Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-01 13:55 -0400
    Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-10-31 16:10 -0700
    Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 01:10 -0700
      Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 01:18 -0700
      Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 01:58 -0700
        Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 02:14 -0700
          Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 02:16 -0700
            Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-02 06:16 -0500
              Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 06:04 -0700
      Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 13:13 -0400

Page 1 of 9  [1] 2 3 4 5 6 7 8 9  Next page →


#16855 — Is there a better way?

FromMark Wills <forthfreak@gmail.com>
Date2012-10-31 04:58 -0700
SubjectIs there a better way?
Message-ID<70a117c1-ba9f-474b-97f3-6440be3d4573@k20g2000vbj.googlegroups.com>
The following routine is checking to see if a string is "}}" i.e.
consists of two consequtive right curly braces.

: }}? ( addr len -- addr len flag)
  dup 2= if
    over dup c@   swap 1+ c@   125 =   swap 125 =   and
  else
    false
  then ;

As can be seen, the first check is the length; if the length is not
exactly 2 then we just return false. If the length is 2 then we check
to see if both characters are ASCII 125. That's the bit I am looking
at and saying "Meh... seems a bit convoluted/lengthy.

Is there a better way?

I was thinking maybe:

... c@ 125 OR swap   1+ c@ 125 OR  125 XOR 0=

Which is perhaps "cleverer" but not as clear as to the intention of
the code and no shorter...

[toc] | [next] | [standalone]


#16856

FromPaul Rubin <no.email@nospam.invalid>
Date2012-10-31 05:22 -0700
Message-ID<7xmwz2u8zi.fsf@ruckus.brouhaha.com>
In reply to#16855
Mark Wills <forthfreak@gmail.com> writes:
> The following routine is checking to see if a string is "}}" i.e.
> consists of two consequtive right curly braces.
>
> : }}? ( addr len -- addr len flag)

    : }? ( caddr -- flag ) c@ 125 = ;
    : }}? ( caddr len -- flag )
        2 = if dup }? swap }? and else 0 then ;

or if you like to live dangerously:

    : }}? ( caddr len -- flag )
        \ assumes caddr points to at least 2 valid chars even if len<2 .
        2 = swap dup }? swap }? and and ;

If you really want to keep the args on the stack (your original type
signature) just put 2dup at the beginning of }}? .

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


#16857

FromMark Wills <forthfreak@gmail.com>
Date2012-10-31 05:44 -0700
Message-ID<55836290-5cf4-4261-908f-cebe2f8209e1@b12g2000vbg.googlegroups.com>
In reply to#16856
On Oct 31, 12:22 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
> Mark Wills <forthfr...@gmail.com> writes:
> > The following routine is checking to see if a string is "}}" i.e.
> > consists of two consequtive right curly braces.
>
> > : }}? ( addr len -- addr len flag)
>
>     : }? ( caddr -- flag ) c@ 125 = ;
>     : }}? ( caddr len -- flag )
>         2 = if dup }? swap }? and else 0 then ;
>
> or if you like to live dangerously:
>
>     : }}? ( caddr len -- flag )
>         \ assumes caddr points to at least 2 valid chars even if len<2 .
>         2 = swap dup }? swap }? and and ;
>
> If you really want to keep the args on the stack (your original type
> signature) just put 2dup at the beginning of }}? .

Thanks Paul!

I think I've settled on:

: }}? ( addr len -- addr len flag)
    dup 2 = if
      over dup  c@ swap  1+ c@ or 125 xor 0=
    else
      false
    then ;

Which is two instructions shorter than my original code.

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


#16866

From"Rod Pemberton" <do_not_have@notemailnotz.cnm>
Date2012-10-31 11:29 -0400
Message-ID<k6rfsn$ue4$1@speranza.aioe.org>
In reply to#16857
"Mark Wills" <forthfreak@gmail.com> wrote in message
news:55836290-5cf4-4261-908f-cebe2f8209e1@b12g2000vbg.googlegroups.com...
...

> I think I've settled on:
>
> : }}? ( addr len -- addr len flag)
>     dup 2 = if
>       over dup  c@ swap  1+ c@ or 125 xor 0=
>     else
>       false
>     then ;

The 'or 125' means it'll detect more than just '}}'.  It'll also detect '}'
followed by a zero or nul too...


Rod Pemberton

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


#16869

From"Rod Pemberton" <do_not_have@notemailnotz.cnm>
Date2012-10-31 11:40 -0400
Message-ID<k6rgi9$nd$1@speranza.aioe.org>
In reply to#16866
"Rod Pemberton" <do_not_have@notemailnotz.cnm> wrote in message
news:k6rfsn$ue4$1@speranza.aioe.org...
> "Mark Wills" <forthfreak@gmail.com> wrote in message
> news:55836290-5cf4-4261-908f-cebe2f8209e1@b12g2000vbg.googlegroups.com...
> ...
>
> > I think I've settled on:
> >
> > : }}? ( addr len -- addr len flag)
> >     dup 2 = if
> >       over dup  c@ swap  1+ c@ or 125 xor 0=
> >     else
> >       false
> >     then ;
>
> The 'or 125' means it'll detect more than just '}}'.  It'll also detect
> '}' followed by a zero or nul too...
>

Sigh, that wasn't as clear as it could be.  125 has many set bits.  So,
or-ing varous values with 125 will result in many other matches.
E.g., 5 or 125 = 125, 112 or 125 = 125, 36 or 125 = 125, etc etc.


RP

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


#16870

FromMark Wills <forthfreak@gmail.com>
Date2012-10-31 08:45 -0700
Message-ID<1c88cb95-3fe6-40ac-890a-b73c56f99fee@s14g2000vba.googlegroups.com>
In reply to#16869
On Oct 31, 3:36 pm, "Rod Pemberton" <do_not_h...@notemailnotz.cnm>
wrote:
> "Rod Pemberton" <do_not_h...@notemailnotz.cnm> wrote in message
>
> news:k6rfsn$ue4$1@speranza.aioe.org...
>
>
>
>
>
> > "Mark Wills" <forthfr...@gmail.com> wrote in message
> >news:55836290-5cf4-4261-908f-cebe2f8209e1@b12g2000vbg.googlegroups.com...
> > ...
>
> > > I think I've settled on:
>
> > > : }}? ( addr len -- addr len flag)
> > >     dup 2 = if
> > >       over dup  c@ swap  1+ c@ or 125 xor 0=
> > >     else
> > >       false
> > >     then ;
>
> > The 'or 125' means it'll detect more than just '}}'.  It'll also detect
> > '}' followed by a zero or nul too...
>
> Sigh, that wasn't as clear as it could be.  125 has many set bits.  So,
> or-ing varous values with 125 will result in many other matches.
> E.g., 5 or 125 = 125, 112 or 125 = 125, 36 or 125 = 125, etc etc.
>
> RP- Hide quoted text -
>
> - Show quoted text -

Good catch, Rod. Guess I'll go back to my original code. Clunky, but
it works!

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


#16967

From"Rod Pemberton" <do_not_have@notemailnotz.cnm>
Date2012-11-02 04:48 -0400
Message-ID<k70166$ac4$1@speranza.aioe.org>
In reply to#16870
"Mark Wills" <forthfreak@gmail.com> wrote in message
news:1c88cb95-3fe6-40ac-890a-b73c56f99fee@s14g2000vba.googlegroups.com...
...

> Guess I'll go back to my original code.

Which was:

> : }}? ( addr len -- addr len flag)
>   dup 2= if
>     over dup c@   swap 1+ c@   125 =   swap 125 =   and
>   else
>     false
>   then ;

OVER DUP C@ 125 = SWAP 1+ C@ 125 = AND


RP

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


#16939

Fromrickman <gnuarm@gmail.com>
Date2012-10-31 21:42 -0400
Message-ID<k6u352$sbp$3@dont-email.me>
In reply to#16869
On 10/31/2012 11:40 AM, Rod Pemberton wrote:
> "Rod Pemberton"<do_not_have@notemailnotz.cnm>  wrote in message
> news:k6rfsn$ue4$1@speranza.aioe.org...
>> "Mark Wills"<forthfreak@gmail.com>  wrote in message
>> news:55836290-5cf4-4261-908f-cebe2f8209e1@b12g2000vbg.googlegroups.com...
>> ...
>>
>>> I think I've settled on:
>>>
>>> : }}? ( addr len -- addr len flag)
>>>      dup 2 = if
>>>        over dup  c@ swap  1+ c@ or 125 xor 0=
>>>      else
>>>        false
>>>      then ;
>>
>> The 'or 125' means it'll detect more than just '}}'.  It'll also detect
>> '}' followed by a zero or nul too...
>>
>
> Sigh, that wasn't as clear as it could be.  125 has many set bits.  So,
> or-ing varous values with 125 will result in many other matches.
> E.g., 5 or 125 = 125, 112 or 125 = 125, 36 or 125 = 125, etc etc.

You are right that the code doesn't work, but he isn't ORing anything 
with 125.  He is oring the two chars which is incorrect.  Each one needs 
to be compared to the value 125.  At least I assume 125 is the right 
ascii value.

How about this?

: }}? ( addr len -- addr len flag )
   2dup s" }}" compare 0= ;

Rick

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


#16962

FromHugh Aguilar <hughaguilar96@yahoo.com>
Date2012-11-01 19:19 -0700
Message-ID<5a70f750-2b4b-4c71-962c-0906bdb5f969@vy11g2000pbb.googlegroups.com>
In reply to#16939
On Oct 31, 6:42 pm, rickman <gnu...@gmail.com> wrote:
> How about this?
>
> : }}? ( addr len -- addr len flag )
>    2dup s" }}" compare 0= ;

Good Forth style is for functions to consume their arguments:

: }}? ( adr cnt -- equal? )
    s" }}" compare 0= ;

If you want a stack picture of ( adr cnt -- adr cnt flag ) then do
this:

2dup }}?

I recommend that Mark read "Thinking Forth." These kinds of style
issues are covered in there.

BTW, Mark: When I wrote symtab, which is a binary tree, this whole
COMPARE thing confused the heck out of me. It is very difficult to
look at the code and understand what the result of COMPARE means. Are
we going left or right, or what? My solution was to define some
constants. I think they were LT EQ and GT as -1, 0 and 1, and compare
the result of COMPARE with these. That really improved the readability
of the code a lot. I did the same later on in ASSOCIATION, which may
be better code for you to study (more useful too, as it is a general-
purpose association array, whereas symtab is only for use as a symbol
table).

With these constants, you would have:

: }}? ( adr cnt -- equal? )
    s" }}" compare EQ = ;

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


#16980

Fromrickman <gnuarm@gmail.com>
Date2012-11-02 13:06 -0400
Message-ID<k70uhq$j2u$1@dont-email.me>
In reply to#16962
On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com>  wrote:
>> How about this?
>>
>> : }}? ( addr len -- addr len flag )
>>     2dup s" }}" compare 0= ;
>
> Good Forth style is for functions to consume their arguments:
>
> : }}? ( adr cnt -- equal? )
>      s" }}" compare 0= ;

This is not what the OP asked for.  I try to give people what they want 
rather than asking them to change what they want to what I prefer to 
offer them... unless that is the only choice of course.

Rick

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


#16982

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-11-02 12:18 -0500
Message-ID<782dnUcywZ3snQnNnZ2dnUVZ8uOdnZ2d@supernews.com>
In reply to#16980
rickman <gnuarm@gmail.com> wrote:
> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com>  wrote:
>>> How about this?
>>>
>>> : }}? ( addr len -- addr len flag )
>>>     2dup s" }}" compare 0= ;
>>
>> Good Forth style is for functions to consume their arguments:
>>
>> : }}? ( adr cnt -- equal? )
>>      s" }}" compare 0= ;
> 
> This is not what the OP asked for.  I try to give people what they want 
> rather than asking them to change what they want to what I prefer to 
> offer them... unless that is the only choice of course.

This is a discussion group, not a helpline; people might get advice
they don't want to hear.  As long as it's good advice, that's just
fine.  And that 2DUP is poor style!

Andrew.

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


#16991

Fromrickman <gnuarm@gmail.com>
Date2012-11-02 14:34 -0400
Message-ID<k713o5$lbp$2@dont-email.me>
In reply to#16982
On 11/2/2012 1:18 PM, Andrew Haley wrote:
> rickman<gnuarm@gmail.com>  wrote:
>> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
>>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com>   wrote:
>>>> How about this?
>>>>
>>>> : }}? ( addr len -- addr len flag )
>>>>      2dup s" }}" compare 0= ;
>>>
>>> Good Forth style is for functions to consume their arguments:
>>>
>>> : }}? ( adr cnt -- equal? )
>>>       s" }}" compare 0= ;
>>
>> This is not what the OP asked for.  I try to give people what they want
>> rather than asking them to change what they want to what I prefer to
>> offer them... unless that is the only choice of course.
>
> This is a discussion group, not a helpline; people might get advice
> they don't want to hear.  As long as it's good advice, that's just
> fine.  And that 2DUP is poor style!
>
> Andrew.

That's your opinion.  There may be a perfectly good reason to include 
the 2DUP.

Rick

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


#16992

FromPaul Rubin <no.email@nospam.invalid>
Date2012-11-02 11:39 -0700
Message-ID<7xk3u397de.fsf@ruckus.brouhaha.com>
In reply to#16991
rickman <gnuarm@gmail.com> writes:
> That's your opinion.  There may be a perfectly good reason to include
> the 2DUP.

I think when a relatively inexperienced user asks a question that
contains an implicit assumption that goes against how experienced users
usually do things, it's appropriate for the folks answering to point out
the issue.

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


#16993

Fromrickman <gnuarm@gmail.com>
Date2012-11-02 14:43 -0400
Message-ID<k7149h$lbp$3@dont-email.me>
In reply to#16992
On 11/2/2012 2:39 PM, Paul Rubin wrote:
> rickman<gnuarm@gmail.com>  writes:
>> That's your opinion.  There may be a perfectly good reason to include
>> the 2DUP.
>
> I think when a relatively inexperienced user asks a question that
> contains an implicit assumption that goes against how experienced users
> usually do things, it's appropriate for the folks answering to point out
> the issue.

That's fine, but the fact remains that I gave him the code he asked for. 
  I believe the "defacto" style suggestion has been pointed out some 
four or five times.  Unlike others here, I don't feel the need to pile on.

Rick

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


#17024

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-11-04 02:36 -0600
Message-ID<U-ydndmTrsu7tAvNnZ2dnUVZ8rCdnZ2d@supernews.com>
In reply to#16993
rickman <gnuarm@gmail.com> wrote:
> On 11/2/2012 2:39 PM, Paul Rubin wrote:
>> rickman<gnuarm@gmail.com>  writes:
>>> That's your opinion.  There may be a perfectly good reason to
>>> include the 2DUP.
>>
>> I think when a relatively inexperienced user asks a question that
>> contains an implicit assumption that goes against how experienced users
>> usually do things, it's appropriate for the folks answering to point out
>> the issue.
> 
> That's fine, but the fact remains that I gave him the code he asked
> for.  I believe the "defacto" style suggestion has been pointed out
> some four or five times.  Unlike others here, I don't feel the need
> to pile on.

But, oddly, you do feel the need to pile on people giving good advice.

Andrew.

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


#17042

Fromrickman <gnuarm@gmail.com>
Date2012-11-04 14:18 -0500
Message-ID<k76f2u$5e3$1@dont-email.me>
In reply to#17024
On 11/4/2012 3:36 AM, Andrew Haley wrote:
> rickman<gnuarm@gmail.com>  wrote:
>> On 11/2/2012 2:39 PM, Paul Rubin wrote:
>>> rickman<gnuarm@gmail.com>   writes:
>>>> That's your opinion.  There may be a perfectly good reason to
>>>> include the 2DUP.
>>>
>>> I think when a relatively inexperienced user asks a question that
>>> contains an implicit assumption that goes against how experienced users
>>> usually do things, it's appropriate for the folks answering to point out
>>> the issue.
>>
>> That's fine, but the fact remains that I gave him the code he asked
>> for.  I believe the "defacto" style suggestion has been pointed out
>> some four or five times.  Unlike others here, I don't feel the need
>> to pile on.
>
> But, oddly, you do feel the need to pile on people giving good advice.
>
> Andrew.

I recognize when I am beating a dead horse.  This is pretty pointless.

Rick

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


#16998

FromMark Wills <forthfreak@gmail.com>
Date2012-11-02 14:38 -0700
Message-ID<6c7a026e-ea57-4bd3-8ca6-0ec7a3d66f98@q4g2000vbg.googlegroups.com>
In reply to#16991
On Nov 2, 6:34 pm, rickman <gnu...@gmail.com> wrote:
> On 11/2/2012 1:18 PM, Andrew Haley wrote:
>
>
>
>
>
>
>
>
>
> > rickman<gnu...@gmail.com>  wrote:
> >> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
> >>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com>   wrote:
> >>>> How about this?
>
> >>>> : }}? ( addr len -- addr len flag )
> >>>>      2dup s" }}" compare 0= ;
>
> >>> Good Forth style is for functions to consume their arguments:
>
> >>> : }}? ( adr cnt -- equal? )
> >>>       s" }}" compare 0= ;
>
> >> This is not what the OP asked for.  I try to give people what they want
> >> rather than asking them to change what they want to what I prefer to
> >> offer them... unless that is the only choice of course.
>
> > This is a discussion group, not a helpline; people might get advice
> > they don't want to hear.  As long as it's good advice, that's just
> > fine.  And that 2DUP is poor style!
>
> > Andrew.
>
> That's your opinion.  There may be a perfectly good reason to include
> the 2DUP.
>
> Rick

Indeed. I don't agree with the notion of having the 2DUP outside of
the definition in this particular case. It was a requirement that the
address and length be retained for further tests (the string might be
something else that I am looking for). Furthermore, in my opinion,
having the 2DUP outside of its associated definition injects 'noise'
into the 'main line' of the code. I prefer to hide the low-level noise
in the lower level functions to which they pertain.

For example:

isOdd? if ... else isEven? then ...

is much nicer than

dup isOdd? if ... else dup isEven? then ...

Lastly, if I choose to remove the test altogether, I only have to
remove the call to }}? in the main line of code. The 2DUP is directly
coupled/associated with the test itself, thus in this particular case
(not every case, sure) I believe the argument for including the 2DUP
inside the definition out-weighs the opposing argument.

So there ;-)

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


#17026

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-11-04 03:01 -0600
Message-ID<0fCdnZJDo-5tswvNnZ2dnUVZ8nWdnZ2d@supernews.com>
In reply to#16998
Mark Wills <forthfreak@gmail.com> wrote:
> On Nov 2, 6:34?pm, rickman <gnu...@gmail.com> wrote:
>> On 11/2/2012 1:18 PM, Andrew Haley wrote:
>>
>> > rickman<gnu...@gmail.com> ?wrote:
>> >> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
>> >>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com> ? wrote:
>> >>>> How about this?
>>
>> >>>> : }}? ( addr len -- addr len flag )
>> >>>> ? ? ?2dup s" }}" compare 0= ;
>>
>> >>> Good Forth style is for functions to consume their arguments:
>>
>> >>> : }}? ( adr cnt -- equal? )
>> >>> ? ? ? s" }}" compare 0= ;
>>
>> >> This is not what the OP asked for. ?I try to give people what they want
>> >> rather than asking them to change what they want to what I prefer to
>> >> offer them... unless that is the only choice of course.
>>
>> > This is a discussion group, not a helpline; people might get advice
>> > they don't want to hear. ?As long as it's good advice, that's just
>> > fine. ?And that 2DUP is poor style!
>>
>> That's your opinion. ?There may be a perfectly good reason to include
>> the 2DUP.
> 
> Indeed. I don't agree with the notion of having the 2DUP outside of
> the definition in this particular case. It was a requirement that the
> address and length be retained for further tests (the string might be
> something else that I am looking for). Furthermore, in my opinion,
> having the 2DUP outside of its associated definition injects 'noise'
> into the 'main line' of the code. I prefer to hide the low-level noise
> in the lower level functions to which they pertain.

While you're entitled to an opinion, this one is just inexperience
talking.  Many beginning Forth programmers think that way, but it's a
mistake.  I think you will, if you keep writing Forth programs, cease
to believe it.  Consistent stack discpline makes it much easier for
the reader to see the flow of data on the stack without having to dig
down to see the stack diagram of every word.

> For example:
> 
> isOdd? if ... else isEven? then ...
> 
> is much nicer than
> 
> dup isOdd? if ... else dup isEven? then ...

No, it's not, because in the former I (and every experienced Forther)
would be looking for the that generated the argument to the isEven? .
Also, isOdd?  doesn't know that a copy of its arg is going to be
needed.  It's much less useful as a factor if you have to clean up
after it every time.

> Lastly, if I choose to remove the test altogether, I only have to
> remove the call to }}? in the main line of code. The 2DUP is directly
> coupled/associated with the test itself, thus in this particular case
> (not every case, sure) I believe the argument for including the 2DUP
> inside the definition out-weighs the opposing argument.
> 
> So there ;-)

You'll learn.  Probably.

Andrew.

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


#17032

FromMark Wills <forthfreak@gmail.com>
Date2012-11-04 03:54 -0800
Message-ID<bfe98488-6f97-497f-9a5f-1959d63759eb@b19g2000vbt.googlegroups.com>
In reply to#17026
On Nov 4, 9:01 am, Andrew Haley <andre...@littlepinkcloud.invalid>
wrote:
> Mark Wills <forthfr...@gmail.com> wrote:
> > On Nov 2, 6:34?pm, rickman <gnu...@gmail.com> wrote:
> >> On 11/2/2012 1:18 PM, Andrew Haley wrote:
>
> >> > rickman<gnu...@gmail.com> ?wrote:
> >> >> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
> >> >>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com> ? wrote:
> >> >>>> How about this?
>
> >> >>>> : }}? ( addr len -- addr len flag )
> >> >>>> ? ? ?2dup s" }}" compare 0= ;
>
> >> >>> Good Forth style is for functions to consume their arguments:
>
> >> >>> : }}? ( adr cnt -- equal? )
> >> >>> ? ? ? s" }}" compare 0= ;
>
> >> >> This is not what the OP asked for. ?I try to give people what they want
> >> >> rather than asking them to change what they want to what I prefer to
> >> >> offer them... unless that is the only choice of course.
>
> >> > This is a discussion group, not a helpline; people might get advice
> >> > they don't want to hear. ?As long as it's good advice, that's just
> >> > fine. ?And that 2DUP is poor style!
>
> >> That's your opinion. ?There may be a perfectly good reason to include
> >> the 2DUP.
>
> > Indeed. I don't agree with the notion of having the 2DUP outside of
> > the definition in this particular case. It was a requirement that the
> > address and length be retained for further tests (the string might be
> > something else that I am looking for). Furthermore, in my opinion,
> > having the 2DUP outside of its associated definition injects 'noise'
> > into the 'main line' of the code. I prefer to hide the low-level noise
> > in the lower level functions to which they pertain.
>
> While you're entitled to an opinion, this one is just inexperience
> talking.  Many beginning Forth programmers think that way, but it's a
> mistake.  I think you will, if you keep writing Forth programs, cease
> to believe it.  Consistent stack discpline makes it much easier for
> the reader to see the flow of data on the stack without having to dig
> down to see the stack diagram of every word.
>
> > For example:
>
> > isOdd? if ... else isEven? then ...
>
> > is much nicer than
>
> > dup isOdd? if ... else dup isEven? then ...
>
> No, it's not, because in the former I (and every experienced Forther)
> would be looking for the that generated the argument to the isEven? .
> Also, isOdd?  doesn't know that a copy of its arg is going to be
> needed.  It's much less useful as a factor if you have to clean up
> after it every time.
>
> > Lastly, if I choose to remove the test altogether, I only have to
> > remove the call to }}? in the main line of code. The 2DUP is directly
> > coupled/associated with the test itself, thus in this particular case
> > (not every case, sure) I believe the argument for including the 2DUP
> > inside the definition out-weighs the opposing argument.
>
> > So there ;-)
>
> You'll learn.  Probably.
>
> Andrew.



Well, a famous man once said: "Opinions are like ass-holes. Everyone
has one, and they're different".

Is there any word naming convention that you (or anyone else) is aware
of that could indicate that a word does not consume its arguments?

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


#17036

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2012-11-04 07:59 -0600
Message-ID<3cqdnSLFxIYw6QvNnZ2dnUVZ8tednZ2d@supernews.com>
In reply to#17032
Mark Wills <forthfreak@gmail.com> wrote:
> On Nov 4, 9:01?am, Andrew Haley <andre...@littlepinkcloud.invalid>
> wrote:
>> Mark Wills <forthfr...@gmail.com> wrote:
>> > On Nov 2, 6:34?pm, rickman <gnu...@gmail.com> wrote:
>> >> On 11/2/2012 1:18 PM, Andrew Haley wrote:
>>
>> >> > rickman<gnu...@gmail.com> ?wrote:
>> >> >> On 11/1/2012 10:19 PM, Hugh Aguilar wrote:
>> >> >>> On Oct 31, 6:42 pm, rickman<gnu...@gmail.com> ? wrote:
>> >> >>>> How about this?
>>
>> >> >>>> : }}? ( addr len -- addr len flag )
>> >> >>>> ? ? ?2dup s" }}" compare 0= ;
>>
>> >> >>> Good Forth style is for functions to consume their arguments:
>>
>> >> >>> : }}? ( adr cnt -- equal? )
>> >> >>> ? ? ? s" }}" compare 0= ;
>>
>> >> >> This is not what the OP asked for. ?I try to give people what they want
>> >> >> rather than asking them to change what they want to what I prefer to
>> >> >> offer them... unless that is the only choice of course.
>>
>> >> > This is a discussion group, not a helpline; people might get advice
>> >> > they don't want to hear. ?As long as it's good advice, that's just
>> >> > fine. ?And that 2DUP is poor style!
>>
>> >> That's your opinion. ?There may be a perfectly good reason to include
>> >> the 2DUP.
>>
>> > Indeed. I don't agree with the notion of having the 2DUP outside of
>> > the definition in this particular case. It was a requirement that the
>> > address and length be retained for further tests (the string might be
>> > something else that I am looking for). Furthermore, in my opinion,
>> > having the 2DUP outside of its associated definition injects 'noise'
>> > into the 'main line' of the code. I prefer to hide the low-level noise
>> > in the lower level functions to which they pertain.
>>
>> While you're entitled to an opinion, this one is just inexperience
>> talking. Many beginning Forth programmers think that way, but it's a
>> mistake. I think you will, if you keep writing Forth programs, cease
>> to believe it. Consistent stack discpline makes it much easier for
>> the reader to see the flow of data on the stack without having to dig
>> down to see the stack diagram of every word.
>>
>> > For example:
>>
>> > isOdd? if ... else isEven? then ...
>>
>> > is much nicer than
>>
>> > dup isOdd? if ... else dup isEven? then ...
>>
>> No, it's not, because in the former I (and every experienced Forther)
>> would be looking for the that generated the argument to the isEven? .
>> Also, isOdd? doesn't know that a copy of its arg is going to be
>> needed. It's much less useful as a factor if you have to clean up
>> after it every time.
>>
>> > Lastly, if I choose to remove the test altogether, I only have to
>> > remove the call to }}? in the main line of code. The 2DUP is directly
>> > coupled/associated with the test itself, thus in this particular case
>> > (not every case, sure) I believe the argument for including the 2DUP
>> > inside the definition out-weighs the opposing argument.
>>
>> > So there ;-)
>>
>> You'll learn. Probably.
> 
> Well, a famous man once said: "Opinions are like ass-holes. Everyone
> has one, and they're different".

Not in this case.  There are some serious disagreements among
experienced Forthers, but this isn't one of them.

> Is there any word naming convention that you (or anyone else) is aware
> of that could indicate that a word does not consume its arguments?

I don't think so.

Andrew.

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


Page 1 of 9  [1] 2 3 4 5 6 7 8 9  Next page →

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


csiph-web