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

Pages: 1-

I know Kung Fu...

Name: Anonymous 2014-06-10 18:39

Show me.

Name: Anonymous 2014-06-10 18:50

This is the worst thread ever.

Name: Anonymous 2014-06-10 18:52

I know Anus Fu...

Name: Anonymous 2014-06-10 19:08

>>3
Probe me.

Name: Anonymous 2014-06-10 19:53

not bumping this thread

Name: Anonymous 2014-06-13 15:26

bump for interest

Name: Anonymous 2014-06-14 6:42

Anus Fu

Name: Anonymous 2014-06-14 7:44

Google Fu

Name: Anonymous 2014-06-14 12:32

Script-Fu

Name: Anonymous 2014-06-14 12:33

Type-Fu.

Name: Anonymous 2014-06-14 13:42

Check out this for loop I've written in Haskell:

for :: STRef s a -> (a -> a) -> (a -> Bool) -> (a -> ST s b) -> ST s ()
for curr iter endTest action = do
currVal <- readSTRef curr
if (endTest currVal)
then do
action currVal
modifySTRef curr iter
for curr iter endTest action
else
return ()

example = do
a <- newSTRef (0 :: Int)
b <- newSTRef (1 :: Int)
for a (+1) (<5) $ \a -> modifySTRef b (*2)
aa <- readSTRef a
bb <- readSTRef b
return (aa, bb)

Name: Anonymous 2014-06-14 14:24

>>11
Your loop is lazy and slow. It doesn't compile into a single "loop label" opcode

Name: Anonymous 2014-06-14 14:34

Here, I've rewritten it a bit:

for :: a -> (a -> a) -> (a -> Bool) -> (a -> ST s b) -> ST s ()
for var step endTest action = do
if (endTest var)
then do
action var
for (step var) step endTest action
else
return ()

example = do
b <- newSTRef (1 :: Int)
for 0 (+1) (<5) $ \a -> modifySTRef b (*(a + 1))
res <- readSTRef b
return res

Name: Anonymous 2014-06-14 14:43

>>12
I'll run some performance tests for ya in a while.

Name: Anonymous 2014-06-14 14:49

>>14

GHC cannot into x86 assembly listings?

Name: Anonymous 2014-06-14 14:59

>>15
It can but they're not really representative as the exact running code will depend on strictness analysis, inline analysis and optimizations performed at the call site. Add to that the ambiguity of 3 code-generators and there's plenty of reasons why people mostly look at Core dumps (the desugared functional language) rather than Assembly dumps.

Name: Anonymous 2014-06-14 15:20

>>16

I guess compiling Haskell is even harder than compiling Scheme.

Name: Anonymous 2014-06-14 16:43

>>17
Scheme is easy. Haskell is easy if you don't care about efficiency.

Name: Anonymous 2014-06-14 16:59

Yep, you were right, it is slow. The Clang-compiled C for-loops do in 0.03 seconds what my Haskell for-loop does in 0.22 seconds. A 7x slowdown in a for loop? Crap.

Name: Anonymous 2014-06-14 17:14

Shit, that was without optimizations on the C side. With -O2 it's 0.024 sec vs 0.537 sec! Fucking 20x slowdown!

Name: Anonymous 2014-06-14 17:20

Name: Anonymous 2014-06-14 17:32

>>21
On my machine it's 5.01 sec for C vs 5.5 sec for Haskell, sorry.

Name: Anonymous 2014-06-14 20:37

>>22
That's because you can't afford a real machine, poorfag!

Name: Anonymous 2014-06-15 4:16

>>19>>20

I can easily jump to 100x slowdown, if compiler fail to analyze continuations and replace them with jumps where possible. I remember the story about Algol compiler written in Algol, which was so slow, compiling 1-byte of source code took and minutes, because of lazy-evaluation.

Name: Anonymous 2014-06-15 4:23

>>24
it

self fix

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