POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: (And in Haskell. Obviously.) Server Time
1 Oct 2024 07:23:37 EDT (-0400)
  Re: (And in Haskell. Obviously.)  
From: Orchid XP v8
Date: 20 Sep 2008 14:07:29
Message: <48d53be1$1@news.povray.org>
>>   What happens if the expression is very long? For example, a function
>> could take a large amount of parameters, all of which are long 
>> expressions
>> using long variable names.
> 
> Put each argument on a seperate line, indented further than the function 
> name.

Or... make them local variables.

(That's more usually done if a certain subexpression is needed more than 
once - since, obviously, putting it in a variable makes it only evaluate 
once. But you can also use it to break things up - especially if what 
you're doing is complicated.)

   let
     thing1 = ...
     thing2 = ...
     thing3 = ...
   in foo thing1 thing2 thing3

Notice that, unlike in "normal" languages, let is an *expression*, but a 
*statement*, so it is valid absolutely anywhere an expression is valid. 
That includes absurd constructions like

   (let x = 5 in x) + (let y = 2 in y)

which just means "5 + 2".

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

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