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


Groups > comp.lang.forth > #12458

Re: Use of VARIABLEs frequent or infrequent? And, C style operators.

Date 2012-05-25 10:05 -1000
From "Elizabeth D. Rather" <erather@forth.com>
Organization FORTH, Inc.
Newsgroups comp.lang.forth
Subject Re: Use of VARIABLEs frequent or infrequent? And, C style operators.
References (1 earlier) <if-dnfnhuZ63EiHSnZ2dnUVZ_hmdnZ2d@supernews.com> <9dOdnS-FfKqwlyLSnZ2dnUVZ_r-dnZ2d@supernews.com> <jpndsd$jhj$1@speranza.aioe.org> <Wu-dnalYGvM9XiLSnZ2dnUVZ_radnZ2d@supernews.com> <jpolqg$t03$1@speranza.aioe.org>
Message-ID <mLednTYtI8m0eyLSnZ2dnUVZ_qmdnZ2d@supernews.com> (permalink)

Show all headers | View raw


On 5/25/12 9:17 AM, Rod Pemberton wrote:
> "Elizabeth D. Rather"<erather@forth.com>  wrote in message
> news:Wu-dnalYGvM9XiLSnZ2dnUVZ_radnZ2d@supernews.com...
...
>>>
>>> Firstly, in my original post, DUP>R was two words:
>>>
>>>     DUP<space>   >R
>>>
>>> It seems you or your newsreader software removed a space (?) ...
>>> (That's not important to me, but you might check.)
>>
>> Dunno. I use Thunderbird, which has never been known to alter spacing.
>>
>
> Well, it did it again above.

I suspect what's going on is a difference between html and text. I use 
text only for these emails, and if you're working in a browser you're 
doing html.  Anyway, not important.

...
>>> It just seems that Forth inserts words or operations directly
>>> into the middle of various common sequences.
>>
>> ??? News to me!
>> What version of Forth are you accusing of doing this?
>>
>
> That would be most of everything I attempt to code in my Forth ... :)  No,
> it's not that bad.  The issue of wrappers to come up every now and then.
> The less specific issue of repeated sequence seems to comes up more
> frequently.  Is OVER + SWAP in loop words common enough to define another
> word for it?  Anyone for O+S ?

The sequence OVER + SWAP is often defined as the word BOUNDS. Tastes 
vary as to whether this improves or impedes readability.

A good clue as to whether a sequence is worth naming is whether it makes 
logical sense that could be captured in an English name, as opposed to 
some functional jargon such as O+S. This one is marginal :-)

>>> So, I'm wanting to create "wrappers" for everything at
>>> this point, i.e., a word before and a word after.  Or, I'm wanting to
>>> create a single word that inserts the difference, e.g., passed an XT
>>> and using EXECUTE.  I've not tried that yet.  It shouldn't be too
>>> difficult.  I wouldn't know if it was ANS compliant...  Although,
>>> perhaps more "generic," I can "see" that definition becoming a bit
>>> larger ...
>>
>> Why would you want to do any of these things?
>>
>
> It seems ... useful?

Well, looking at the code you originally posted (putting the spaces back 
in):

: AND! ( x addr -- ) DUP >R @ AND R>  ! ; \  C's&=
: OR! ( x addr -- ) DUP >R @ OR R>  ! ; \  C's |=
: XOR! ( x addr -- ) DUP >R @ XOR R>  ! ; \  C's ^=

: +! ( x addr -- ) DUP >R @ + R>  ! ; \  C's +=
: -! ( x addr -- ) DUP >R @ - R>  ! ; \  C's -=
: *! ( x addr -- ) DUP >R @ * R>  ! ; \  C's *=

: /! ( x addr -- ) SWAP OVER @ SWAP / SWAP ! ; \  C's /=
: MOD! ( x addr -- ) SWAP OVER @ SWAP MOD SWAP ! \  C's %=
: LSHIFT! ( x addr -- ) SWAP OVER @ SWAP LSHIFT SWAP ! ; \  C's<<=
: RSHIFT! ( x addr -- ) SWAP OVER @ SWAP RSHIFT SWAP ! ; \  C's>>=

...I do see a lot of what you're calling "wrappers". But I'm disagreeing 
with the style of programming that would use *any* of these words, with 
the exception of +! (which is normally defined as a code sequence, both 
shorter and simpler than the high-level mess above).

>> This sounds like a lot of unnecessary machinery, to me. It's as though
>> you are wanting to take Forth, which is a very simple language, and make
>> it as complicated as others you're more familiar with.
>
> Ok.

If you want to program in C, that's fine. If you want to program in 
Forth, you should accept that Forth is a very different language from C, 
both in ideomatic style and in economics (what's efficient both for the 
programmer and for runtime). Trying to make equivalences to functions 
you're accustomed to in C and then using them to write programs will 
lead to code which is tortuously inefficient to run and very much more 
difficult to maintain.

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."
==================================================

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


Thread

Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-22 16:01 -0400
  Re: Use of VARIABLEs frequent or infrequent? And, C style operators. Mark Wills <markrobertwills@yahoo.co.uk> - 2012-05-22 14:58 -0700
  Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Ed" <invalid@nospam.com> - 2012-05-23 13:19 +1000
    Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-22 23:44 -0700
      Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Nomen Nescio <nobody@dizum.com> - 2012-05-23 12:30 +0200
        Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-23 08:37 -0700
          Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-23 23:32 -0700
            Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. stephenXXX@mpeforth.com (Stephen Pelc) - 2012-05-24 13:24 +0000
              Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-24 09:40 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. stephenXXX@mpeforth.com (Stephen Pelc) - 2012-05-24 20:52 +0000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-24 14:17 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. stephenXXX@mpeforth.com (Stephen Pelc) - 2012-05-25 08:10 +0000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-25 01:50 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Fritz Wuehler <fritz@spamexpire-201205.rodent.frell.theremailer.net> - 2012-05-25 22:39 +0200
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Paul Rubin <no.email@nospam.invalid> - 2012-05-26 22:02 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Nomen Nescio <nobody@dizum.com> - 2012-05-25 14:33 +0200
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. stephenXXX@mpeforth.com (Stephen Pelc) - 2012-05-25 16:50 +0000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-05-25 20:30 +0000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. hwfwguy@gmail.com - 2012-05-30 11:23 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Peter Knaggs" <pjk@bcs.org.uk> - 2012-05-29 20:00 +0100
      Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-24 07:39 -0400
        Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-24 15:37 +0000
  Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-22 21:18 -1000
    Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-24 18:27 -1000
      Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-25 03:55 -0400
        Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-25 07:38 -1000
          Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-25 15:17 -0400
            Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-25 10:05 -1000
              Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-26 08:02 -0400
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Coos Haak <chforth@hccnet.nl> - 2012-05-26 14:31 +0200
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Doug Hoffman <glidedog@gmail.com> - 2012-05-26 09:55 -0400
                Re: Use of VARIABLEs frequent or infrequent? And, C style operators. BruceMcF <agila61@netscape.net> - 2012-05-26 07:04 -0700
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-26 09:41 -1000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-05-26 19:52 -0400
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-26 19:49 -1000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Ed" <invalid@nospam.com> - 2012-06-01 13:39 +1000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-31 19:27 -1000
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-06-01 18:24 -0400
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-06-02 03:09 -0500
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-27 02:23 -0500
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Harry Vaderchi" <admin@127.0.0.1> - 2012-05-27 11:54 +0100
                Re: Use of VARIABLEs frequent or infrequent?  And, C style operators. "Elizabeth D. Rather" <erather@forth.com> - 2012-05-27 07:25 -1000
                Re: Use of VARIABLEs frequent or infrequent? And, C style operators. Alex McDonald <blog@rivadpm.com> - 2012-05-27 11:13 -0700

csiph-web