Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Linked lists considered harmful

Name: Anonymous 2009-10-10 20:46

  ↑    slava_pestov 4 points 5 hours ago [-]
  ↓    A perfect illustration of why single linked lists are simply the wrong data structure in
        99% of cases. Just use arrays and you won't have to choose between tail recursion, and
        front-to-back iteration order.
        permalink report reply

Name: Anonymous 2009-10-10 23:30

>>37
Do you disagree about excessive variable use making functions hard to understand?

How's this for long but readable thanks to structure? You may just have to wait until you happen to see an example you like, since I'm going out soon.
[m]: menu-rotations-4D ( -- gadget )
    3 3 <frame>
        { 1 1 } >>filled-cell
         <pile> 1 >>fill
          "XY +" [ drop rotation-step 4D-Rxy rotation-4D ]
                button* add-gadget
          "XY -" [ drop rotation-step neg 4D-Rxy rotation-4D ]
                button* add-gadget
       @top-left grid-add   
        <pile> 1 >>fill
          "XZ +" [ drop rotation-step 4D-Rxz rotation-4D ]
                button* add-gadget
          "XZ -" [ drop rotation-step neg 4D-Rxz rotation-4D ]
                button* add-gadget
       @top grid-add   
        <pile> 1 >>fill
          "YZ +" [ drop rotation-step 4D-Ryz rotation-4D ]
                button* add-gadget
          "YZ -" [ drop rotation-step neg 4D-Ryz rotation-4D ]
                button* add-gadget
        @center grid-add
         <pile> 1 >>fill
          "XW +" [ drop rotation-step 4D-Rxw rotation-4D ]
                button* add-gadget
          "XW -" [ drop rotation-step neg 4D-Rxw rotation-4D ]
                button* add-gadget
        @top-right grid-add  
         <pile> 1 >>fill
          "YW +" [ drop rotation-step 4D-Ryw rotation-4D ]
                button* add-gadget
          "YW -" [ drop rotation-step neg 4D-Ryw rotation-4D ]
                button* add-gadget
       @right grid-add   
         <pile> 1 >>fill
          "ZW +" [ drop rotation-step 4D-Rzw rotation-4D ]
                button* add-gadget
          "ZW -" [ drop rotation-step neg 4D-Rzw rotation-4D ]
                button* add-gadget
       @bottom-right grid-add   
;[m]

Name: Anonymous 2009-10-11 20:44

>>45
I disagree because there's a point where you can factor out functions but you can't really come up with meaningful names for them, so you end up with lots of tiny functions with weird ass names, but in concatenative languages you kinda have no choice but to do just that, because otherwise the stack juggling mental overhead that would ensue would drive you (and everyone who touches your code) insane. Some times it's easier to come up with meaningful variable names than names for artificially factored out functions.
Example?

Plus I was asking for an example of extreme factoring's superiority over sensible variable naming, specifically one that coul only work in concatenative languages. That example right there can be reproduced in any OO language or  any language that supports currying.
That was an example of a readable long function.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List