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-11 0:35

Name: Anonymous 2009-10-11 0:43

>>41
submitted 3 hours ago by Seppler90000

ಠ_ಠ

Name: Anonymous 2009-10-11 3:31

your face is considered harmful

Name: Anonymous 2009-10-11 13:20

>>38
Not if I go out first, which I did.

Name: Anonymous 2009-10-11 13:51

>>38
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. 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.

Name: Anonymous 2009-10-11 15:28

>>41
MrVacBob responded!

Name: Anonymous 2009-10-11 15:37

>>38
Here's a factoring challenge for you. I have this Forth code here (modified from a piece of Forth code I wrote some time ago, works on GForth) that makes extensive use of local variables. If you can turn this into a readable, variable-free, more finely factored code, I will totaly believe everything you said about the concatenative approach. I would ask that you keep it in Forth so we could test the advantages of concatenativity alone.

: exchange ( addr1 addr2 -- ) dup c@ rot dup c@ -rot c! swap c! ;
\ exchanges the contents of two character addresses.

: permuts_do_loop { set set_size permut permut_size action -- }
   set permut permut_size + = if
       permut permut_size action execute
   else
      set_size 1- dup to set_size for
         set dup i chars + 2dup exchange
         set char+ set_size permut permut_size action recurse
         exchange
      next
   endif
;

: permuts_do ( set set_size permut_size action ) 2>r over 2r> permuts_do_loop ;

s" 0123456789" 2constant 0_to_9

0_to_9 4 :noname type cr ; permuts_do
0_to_9 type cr bye

Name: Anonymous 2009-10-11 20:04

Slava is a motherfucking troll, and his pet language is awful.

/thread

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.

Name: Anonymous 2009-10-11 21:53

>>49
Example?
See >>47

Name: Anonymous 2009-10-12 4:59

>>40
Aw, man TTFF?

Name: Anonymous 2009-10-14 18:50

bump

Name: Anonymous 2009-10-14 18:56

>>52
I am very disappointed in you :(

Name: Anonymous 2009-10-14 20:08

>>53
And I'm disapointed in >>38,49. Such is life.

Name: Anonymous 2009-10-14 21:52

>>54
>>38,49 here. I'd like to try your challenge, but I haven't had time yet.

Name: Anonymous 2009-10-14 22:12

>>55
Ok then. Here's a slightly cleaner looking version.

: exchange ( addr1 addr2 -- ) tuck c@ -rot tuck c@ swap c! c! ;
\ exchanges the contents of two character addresses.

: permuts_do_loop { set set_size permut permut_size action -- }
   set permut permut_size + = if
       permut permut_size action execute
   else
      set_size 0 +do
         set dup i chars + 2dup exchange
         set char+ set_size 1- permut permut_size action recurse
         exchange
      loop
   endif
;

: permuts_do ( set set_size permut_size action -- )
   2>r over 2r> permuts_do_loop
;

s" 0123456789" 2constant 0_to_9

0_to_9 4 :noname type cr ; permuts_do
0_to_9 type cr bye

Name: Anonymous 2010-12-09 0:41

Name: Anonymous 2011-02-03 4:24

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