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,061 of 117,927   
   dxf to Paul Rubin   
   Re: quotations   
   09 Feb 25 21:03:48   
   
   From: dxforth@gmail.com   
      
   On 9/02/2025 6:41 pm, Paul Rubin wrote:   
   > dxf  writes:   
   >> quotations ... strike me as being wrong in every way, not least   
   >> because they are intended to feature prominently, stuffed in one's   
   >> face.  I don't understand the appeal at all.   
   >   
   > I never got the impression they were supposed to be so prominent, though   
   > I guess one could program in a style that uses them heavily.   
      
   IMO it does nothing for readability to see a definition interrupted by another.   
   My reaction is one of WTF.   
      
   > My first   
   > Forth program used a lot of XT's but in retrospect, it was rather   
   > unidiomatic.   
   >   
   > The following sort of follows an idiom for Python GUI programs.  You   
   > have a function MAKE-BUTTON that puts a button on the screen.  The   
   > button has a label, and it calls a function when you press it.  This   
   > is using the notation from Anton's post but I haven't tested it.   
   >   
   >    : make-button ( a u xt -- ) ... ;   
   >        \ a u is the label, xt is the action   
   >   
   > Now you want to draw buttons for a numeric keypad:   
   >   
   >    : make-action ( n -- xt ) [n:d ." You pressed " . ] ;   
   >    : make-label ( n -- a u )  \ make a string like "5" in the dictionary   
   >         here { a } 1 chars allot  '0' + a c! a 1 ;   
   >   
   >    : keypad ( -- ) 10 0 do   
   >                       i make-label i make-action make-button   
   >                    loop ;   
   >   
   > Now there will be buttons labelled "0", "1", ... "9", and and when you   
   > press one, it will print "you pressed 5" or whatever for that button.   
   >   
   > I think the idiomatic old-school Forth alternative to this would be an   
   > OOP-like approach, but the above is probably more concise, and to some   
   > of us more intuitive.   
      
   I don't understand make-action at all.  What is it meant to be doing?   
   Call me boring but I don't like inventing new syntax only to have to   
   re-learn what it does when I have to come back and maintain it.  Not   
   sure if it applies to yours but ANS A.6.2.0455 gives an example of a table   
   of code fragments using :NONAME.  IMO such instances are rare enough to   
   not require sugar-coating.  I'm aware of quotations being used in DOES>   
   code, words having multiple xt's etc but to me this is the antithesis of   
   Forth - the opposite of being simple.   
      
   --- 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