home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 117,244 of 117,927   
   Hans Bezemer to Hans Bezemer   
   Re: "The Best Programming Language for t   
   27 Apr 25 13:33:23   
   
   From: the.beez.speaks@gmail.com   
      
   On 27-04-2025 12:28, Hans Bezemer wrote:   
   > On 27-04-2025 08:21, dxf wrote:   
   >> On 26/04/2025 9:07 pm, albert@spenarnc.xs4all.nl wrote:   
   >>> In article ,   
   >>> dxf   wrote:   
   >>>> On 26/04/2025 2:34 am, Hans Bezemer wrote:   
   >>>>> ...   
   >>>>> Yeah, I have helped to make a proposal for PLACE and +PLACE - which   
   >>>>> never even made it to the voting stage.   
   >>>>   
   >>>> It's a nice symmetry.  OTOH the remaining vendors use APPEND and why   
   >>>> should they change?   
   >>>>   
   >>>   
   >>> $+! was even earlier. It predates the IBM PC XT.   
   >>> (Osborne, CP/M)   
   >>   
   >> Even PLACE was new back then!   
   >>   
   >> String stacks often had $+ or equiv.  Somehow I never took to them.   
   >> Not enough applications that warranted the effort?   
   >   
   > Let's face it - the string support was notoriously bad in Forth. People   
   > openly complained about that.   
   >   
   > So when I did 4tH I ported some of my string libraries in C to Forth,   
   > https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.s   
   c/lib/replace.4th   
   >   
   > Never used it. Ok, maybe once or twice. Because all I actually needed   
   > was PLACE and +PLACE. You can compose a lot of things with those two.   
   > Other frequently used tools: CLIP ( a n -- a n-1) and CHOP ( a n - a+1   
   > n-1). Tip: see how often you use 1 /STRING - that'll give you an idea.   
   > And that from a man who has done some text processing in his life..   
   >   
   >  >NUMBER? Never use it - too weird. My own NUMBER is great. SEARCH?   
   > Never use it. Rather use my own INSTR routine that simply returns a   
   > position or a pointer. Doesn't need COMPARE either. BTW, COMPARE is   
   > rather useful..   
   >   
   > So with a few minor additions there is nothing wrong with the text   
   > processing capabilities of Forth, actually.   
   >   
   > Just a shame the very basics are missing. The only thing holding Forth   
   > back is the refusal to abstract strings. Wanna make it a counted string   
   > with a cell count? Do it. Wanna keep on doing counted strings? Do it.   
   > Wanna do ASCIIZ strings? No problem.   
   >   
   > All you need is a word that initializes a string - like PLACE. A word   
   > that appends to an existing string, +PLACE. And a word that converts a   
   > string to a string/count, like COUNT. Add a word that converts a   
   > character to a string: C>S:   
   >   
   > 32 string MyStr               \ create a string that can hold   
   32 chars   
   > s" This is my life" MyStr PLACE   
   > char ! C>S MyStr +PLACE   
   >   
   > Another handy word is >STRING that converts a "raw" string to a fully   
   > qualified string ( a1 n1 -- a2) that can handle a COUNT (you have the   
   > carnal knowledge - you take care of the "how"). E.g. for counted strings   
   > it might be:   
   >   
   > : >STRING swap over over dup char+ rot cmove c! ;   
   >   
   > Yeah, you take care of the available string capacity. It's Forth, baby!   
   >   
   > Now, how much wiggle room do you need additionally to do your very   
   > special string stuff? Especially when we had this wonderful CHAR+ and   
   > CHARS abstractions that you so carelessly discarded?   
   >   
   > Sure, it might give rise to a whole explosion of string formats - but   
   > does that matter if they're all compatible at the abstraction level?   
   >   
   > I have introduced a light dynamic string format in 4tH a while ago. It   
   > only contains the equivalents of PLACE, +PLACE and  COUNT - and I'm   
   > still astonished how versatile it is. C>S is still useful, but I haven't   
   > needed >STRING yet.   
   >   
   > Take this example from FFL est, which I had to change from:   
   >   
   >    end-of-line count tuck r@ count + swap cmove r@ c@ + r@ c!   
   >   
   > To:   
   >   
   >    0 end-of-line count tuck r@ count + dup >r swap cmove chars r> + c!   
   >   
   > All can be replaced (portably) by:   
   >   
   >    end-of-line r@ +place   
   >   
   > That's it. Works for you, works for me. It's much easier.   
   >   
   > Hans Bezemer   
      
   As a matter of fact, the entire EST routine   
   (https://github.com/irdvo/ffl/blob/master/ffl/est.fs) could be written   
   _portably:_   
      
   : parse-esc   ( c-addr1 u1 c-addr2 -- c-addr3 u3 )   
      over IF   
        >r over c@   
        dup [char] x = IF drop chop r> est-add-2hex ;THEN   
        dup [char] m = IF drop 13 c>s r@ +place 10 c>s r> +place chop ;THEN   
        dup [char] n = IF drop end-of-line r> +place chop ;THEN   
        dup [char] a [char] z 1+ within IF [char] a - chars est-table THEN   
        c>s r> +place chop   
      ;THEN drop   
      
      
   Which is IMHO *FAR* more readable and compact than the original. *NO*   
   carnal knowledge required!   
      
   Hans Bezemer   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca