POV-Ray : Newsgroups : povray.off-topic : 10 things to use a Min Heap for : Re: (Tainted) Server Time
7 Sep 2024 23:24:10 EDT (-0400)
  Re: (Tainted)  
From: Darren New
Date: 20 Jun 2008 16:56:18
Message: <485c1972$1@news.povray.org>
Orchid XP v8 wrote:
> I meant that you could write the loop and the processing logic as a 
> single function, if you really wanted to. 

I've done that, by declaring a lambda that I then pass somehere else. 
It's uglier in Erlang, is all.

> True, but there shouldn't be very many of those.

It's still bad engineering. :-)

>> I.e., since looping requires recursion, every time you change what 
>> data persists between iterations, you have to change all the recursive 
>> calls. Maybe the state monad helps, and you could probably do the same 
>> thing by wrapping your stuff in a record in Erlang, but that's just 
>> really covering up the problem, in some ways.
> 
> Not sure what gave you that idea... Add a field to the data structure, 
> and only the places that use that new field have to care about it. It's 
> a lot less work than passing lots of parameters individually.

For one, you wind up passing everything in the record to every function, 
whether it needs it or not.

Say I want a counter for how many times I call X. That goes in the 
record, and X increments it.  But it also gets passed to Y and Z.

> Parsec allows you to write parsers without needing to explicitly build 
> state machines. 

Yeah. Erlang has the same sort of thing, called gen_fsm.

It's still not obvious when you're actually using the control flow 
(i.e., the program counter) as part of your state how the control flows. 
That's probably my problem - still used to using the PC as part of the 
program state.

> Hmm, let's see:
> 
>   word <- untilM valid_word ask_for_word
>   numb <- untilM valid_numb ask_for_numb
> 
> (Haskell has a function called "until", but there is no untilM function 
> for some reason. However, it is not hard to implement.)
> 
> Depending on how complex the validity and requesting code is, 

Part of the problem is that you're supposed to crash out in Erlang if 
you get an error. So saying "did you read an integer" at all is a mess.

> Well... I guess it depends on just how complex your flow control is. 

Yeah. I actually even wrote up the control flow, somewhere.  Anyway, 
just saying, that's the problem right now. Every choice winds up being 
nested and nested, unless i'm just doing something wrong. </rant>

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.