POV-Ray : Newsgroups : povray.general : Pov 4.00 question Server Time
2 Dec 2026 20:03:28 EST (-0500)
  Pov 4.00 question (Message 51 to 73 of 73)  
<<< Previous 50 Messages Goto Initial 50 Messages
From: Peter J  Holzer
Subject: Re: Pov 4.00 question
Date: 2 Feb 2002 10:01:13
Message: <slrna5npcm.1ag.hjp-usenet@teal.h.hjp.at>
On 2002-01-30 21:55, Warp <war### [at] tagpovrayorg> wrote:
> Jan Walzer <jan### [at] lzernet> wrote:
> : you mean, if it would something like the following, it wouldn't be OO ?
> 
>   Precisely. What you described is a typical modular language.
>   Modular languages (eg. Modula 2) can have classes, member variables,
> member functions, public and private parts, etc, but if they don't support
> inheritance and dynamic binding, they are not OO.

Modula 2 doesn't have classes (unless you have a very different concept
of "class" than me - to me a class is a set of similar things - if there
can by definition be only one thing per class, its not a class).
Modules are nothing more than name spaces. It does have dynamic binding, though.

	hp


-- 
   _  | Peter J. Holzer    |
|_|_) | Sysadmin WSR       | In case of emergency break laws of physics.
| |   | hjp### [at] hjpat         |
__/   | http://www.hjp.at/ | 	-- Stephen Baxter


Post a reply to this message

From: Christopher James Huff
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 2 Feb 2002 11:42:08
Message: <chrishuff-1C20F9.11432302022002@netplex.aussie.org>
In article <Xns### [at] 204213191226>,
 Jordan <hookflash@_hotmail_.com> wrote:

> I *really* hope the sdl gets completely redone for pov 4.  Imo, an object-
> oriented approach would be much cleaner & prettier.  I would love to see a 
> more powerful sdl (cleaner (no more '{'s and '#'s, for example),

No more '{'s? That would make it much harder to read, not to mention 
more typing. What would you do, replace them with "begin" and "end" 
keywords, like pascal?
I'd eliminate the existing #end keyword, replacing it with {} blocks. 
The "#" character would only be used for "preprocessor" directives.


> user- defined data types,

Just the ability to attach variables and macros to objects should be 
enough here...you could do things like a lens flare "object". If there 
were object references, you could even make a linked list...


> Has anyone considered using an existing scripting language, such as 
> Lua or Python, as the pov sdl?  

These languages aren't really made for scene description...you would 
have to modify them pretty heavily before you got something that looked 
like a scene description language instead of an API.
I've seen Lua before...it looks very interesting. It seems to base 
everything on associative arrays.


> This is *exactly* the sort of thing these langs were designed for.

Not really...

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Kevin Wampler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 2 Feb 2002 22:54:16
Message: <3C5CB5DB.7970FB10@u.arizona.edu>
Jordan wrote:
>  Has
> anyone considered using an existing scripting language, such as Lua or
> Python, as the pov sdl?

In the current scene I'm working on I have been using Icon extensively
to generate Pov code.  It's a bit awkward with vectors since there is no
operator overloading (so I have things like add(v1, v2)), but other
features of the language, especially backtracking combined with
goal-directed evaluation have made it quite worth my while.  While I do
think that there are many aspects of languages which could make Pov
scripting nicer and easier (I know there's some parts of Icon I would
love to have in there), for the most part I have found that writing
programs in other languages to output Pov code is not too much harder
(with the exception of some missing functions, like trace) than I
imagine writing in a modified Pov sdl would be.  After all,
macro("name", a, b, c, ... ) as I have been writing in Icon isn't much
harder than the #macro name(a, b, c , ... ) I would write in Pov.

	~Kevin Wampler~


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 3 Feb 2002 04:45:13
Message: <3c5d06a9@news.povray.org>
In article <3C5CB5DB.7970FB10@u.arizona.edu> , Kevin Wampler 
<wam### [at] uarizonaedu>  wrote:

> In the current scene I'm working on I have been using Icon extensively
> to generate Pov code.

Don't even get me started on Icon.  With its random (well, random to any sane
person) sequences of characters being operators, it can only appear a useful
language to those who designed it.  For everybody else its useless syntax gets
in the way all time.  Readability of a programming language is the most
important asset, and the designers of Icon did a good job.  Given L is a list,
who could tell "every i:=1 to *L/2 do L[i]:=:L[-i]" reverses it?  Not that is
is to be considered obfuscated code at all, no, this is how it is presented in
books that want to teach the language!

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: fro### [at] iitedu


Post a reply to this message

From: Ron Parker
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 3 Feb 2002 10:36:38
Message: <slrna5qm88.91d.ron.parker@fwi.com>
On Sun, 03 Feb 2002 10:45:10 +0100, Thorsten Froehlich wrote:
> 
> Given L is a list,
> who could tell "every i:=1 to *L/2 do L[i]:=:L[-i]" reverses it?  

Hm, that would work in Perl, too, with very few modifications.  

Of course, @L = reverse @L would work, too...

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 3 Feb 2002 10:59:10
Message: <3c5d5e4e@news.povray.org>
In article <slr### [at] fwicom> , Ron Parker 
<ron### [at] povrayorg>  wrote:

>> Given L is a list,
>> who could tell "every i:=1 to *L/2 do L[i]:=:L[-i]" reverses it?
>
> Hm, that would work in Perl, too, with very few modifications.
>
> Of course, @L = reverse @L would work, too...

I picked a short example.  Below is a scanner, also given as *educational*
example (from http://www.iit.edu/~tc/), in particular note sequences like
"||:= =", or the operators for connecting strings, because that is what the
"++" does.  Now guess what the "?" does!

Basically all operators are unqiue for each data type, which gives you a farm
of operators.  In order to implement those you end up with other interesting
character sequences like "~==="...

    Thorsten


procedure scan()
local t,c,b
static whiteSpace,initIdChars,idChars,hexdigits,commentDepth,commentLineNo
initial {
 /inputFile := &input
 inputLineNumber := 1
 inputColumn := 1
 inputLine := read(inputFile)
 eoiToken := &null
 whiteSpace := &ascii[1:34] #control ++ blank
 initIdChars := &letters
 hexdigits := &digits ++ 'ABCDEF'
 idChars := &letters ++ &digits ++ '$_'
 keywordSet := set([
  "DEF","VAL","while","bu"
 ])
}
if \eoiToken then return eoiToken
repeat inputLine ? {
 tab(inputColumn)
 tab(many(whiteSpace))
 c := &pos
 if b := (tab(any('+-'))|"") ||
   tab(many(&digits)) then {
  if b := b || fractionPart() ||
      scaleFactor() then {
   t := Token("signedFloat",b,
    inputLineNumber,c)
  } else if b ||:= fractionPart() then {
   t := Token("signedFloat",b,
    inputLineNumber,c)
  } else if b ||:= ="." || scaleFactor() then {
   t := Token("signedFloat",b,
    inputLineNumber,c)
  } else {
   t := Token("signedInt",b,
    inputLineNumber,c)
  }
  inputColumn := &pos
  return t
 } else
  if any(initIdChars) then {
  t := Token("ident",tab(many(idChars)),
   inputLineNumber,c)
  inputColumn := &pos
  if member(keywordSet,t.body) then
   t.type := t.body
  return t
 } else
  if b := =("~=" | ">=" | "<=" | "->") then {
  inputColumn := &pos
  return Token(b,b,inputLineNumber,c)
 } else
  if ="(*" then {
  inputColumn := &pos
  commentDepth := 1
  commentLineNo := inputLineNumber
  while commentDepth > 0 do {
   tab(upto('*(')|0)
   if pos(0) then {
       &pos := 1
       inputLineNumber +:= 1
       if not (&subject :=
     inputLine := read(inputFile))
       then {
    eoiToken := Token("EOI","EOI",
     inputLineNumber,1)
    write("end of input in comment beginning at ",
     commentLineNo)
    return eoiToken
       }
    } else if ="*)" then {
     commentDepth -:= 1
    } else if ="(*" then {
     commentDepth +:= 1
    } else {
     move(1)
    }
  }
  inputColumn := &pos
 } else
  if b := tab(any('\',=()[]<>+-*/@;:.')) then {
  inputColumn := &pos
  return Token(b,b,inputLineNumber,c)
 } else
  if pos(0) then {
  inputColumn := 1
  inputLineNumber +:= 1
  if not (inputLine := read(inputFile)) then {
   eoiToken := Token("EOI","EOI",
     inputLineNumber,1)

   return eoiToken
  }
 } else
  if ="\"" then {
  b := tab(find("\""))
  if not( = "\"" ) then {
   write("unterminated string at ",
    inputLineNumber," ",c)
  }
  t := Token("string",b,inputLineNumber,c)
  inputColumn := &pos
  return t
 } else
  {
  write("unexpected character: ",move(1),
   " at line ",inputLineNumber," column ",c)
  inputColumn := &pos
 }
}
end


Post a reply to this message

From: Hermann Voßeler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 06:56:03
Message: <3C6BA3F8.7010104@webcon.de>
Warp wrote:

> 
>   I don't understand why it would be "more powerful" and "cleaner" with
> no '{'s and '#'s.
>   Specially the lack of '{'s would make it uglier and harder to write and
> read.
>   (No, I *DON'T* want to start writing 'begin' and 'end' like in Pascal.)
> 
> 

may I throw in my $.02 on this?

do you know the haskell (funcitonal) programming language?


they use a indentation rule to figure out when a statement belongs to 
a block. As long as you indent new lines more than the line that 
started the block, the compiler knows you want to stay within that 
block. As soon as you indent lesser, it adds a implicit "}".
Works great.

For povray SDL this whould mean:

object sphere
   <0 0 1> 1.0
   texture
      pigment colour rgb(1, 1, 0)
      finish ambient 0.2
             diffuse 0.6
             metallic

camera location <0 0 0>
        look_at <0 0 1>


Hermann Voßeler


Post a reply to this message

From:
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 07:12:43
Message: <7aan6uohose2fi918tja79tdn80kpvv7kt@4ax.com>
On Thu, 14 Feb 2002 12:48:08 +0100, Hermann Vo�eler <h.v### [at] webconde>
wrote:
> they use a indentation rule to figure out when a statement belongs to 
> a block

But in case of complicated mesh2 it could be horrible wasting of drive space.

ABX


Post a reply to this message

From: Nekar Xenos
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 07:17:32
Message: <3c6baadc@news.povray.org>
"Hermann Voßeler" <h.v### [at] webconde> wrote in message
news:3C6### [at] webconde...
> Warp wrote:
>
> >
> >   I don't understand why it would be "more powerful" and "cleaner" with
> > no '{'s and '#'s.
> >   Specially the lack of '{'s would make it uglier and harder to write and
> > read.
> >   (No, I *DON'T* want to start writing 'begin' and 'end' like in Pascal.)
> >
> >
>
> may I throw in my $.02 on this?
>
> do you know the haskell (funcitonal) programming language?
>
>
> they use a indentation rule to figure out when a statement belongs to
> a block. As long as you indent new lines more than the line that
> started the block, the compiler knows you want to stay within that
> block. As soon as you indent lesser, it adds a implicit "}".
> Works great.
>
> For povray SDL this whould mean:
>
> object sphere
>    <0 0 1> 1.0
>    texture
>       pigment colour rgb(1, 1, 0)
>       finish ambient 0.2
>              diffuse 0.6
>              metallic
>
> camera location <0 0 0>
>         look_at <0 0 1>
>

IMHO it's not all that practical. If you have lot's of nested loops and CSG you
could spend more time scrolling left and right than it would take to type in
'{'. It could get quite confusing. I would rather just do away with the #'s.

--
#local X=20*<-2,2,5>;#local K=2*z*X-X;#local R=seed(frame_number);blob{#while(K
.x>X.x)#local N=X+<rand(R)rand(R)1>/3;#local X=(vlength(N-K)<vlength(X-K)?N:2*X
-N);sphere{X,1,1rotate z*90}sphere{X,1,1}#end pigment{rgbt 1}interior{media{
emission<2,4,5>*5}}hollow scale.05}//   http://nekar_xenos.tripod.com/metanoia/
sphere_sweep{catmull_rom_spline 6<-8,-8>1<-8,-8>1<-8,8>1<8,-8>1<8,8>1<8,8>1
translate 20*z pigment{gradient z scale 3color_map{[0rgb<0,9,18>][1rgb 0]}}}


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.323 / Virus Database: 180 - Release Date: 2002/02/08


Post a reply to this message

From: Tom Melly
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 07:19:46
Message: <3c6bab62$1@news.povray.org>
"Hermann Voßeler" <h.v### [at] webconde> wrote in message
news:3C6### [at] webconde...

<snip>

Might be worth implementing if only to see Ken turning in his grave.... ("But
he's not dead", "No, but this will kill him")

I don't like it, although I can see the attraction. It strikes me as mixing up
style and content - which is exactly the confusion that got html/browsers in to
such trouble....


Post a reply to this message

From: Hermann Voßeler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 09:14:39
Message: <3C6BC474.1010002@webcon.de>
W^(3)odzimierz ABX Skiba wrote:

> On Thu, 14 Feb 2002 12:48:08 +0100, Hermann Vo�eler <h.v### [at] webconde>
> wrote:
> 
>>they use a indentation rule to figure out when a statement belongs to 
>>a block
>>
> 
> But in case of complicated mesh2 it could be horrible wasting of drive space.
> 
> ABX
> 

I didn't mention that, but in haskell you are not bound to use
the layout-rule. You can as well go on and type as many {{{braces}}}
as you like. Only if you open a block without using a brace, the
compiler can figure out by indentation.


Post a reply to this message

From: Hermann Voßeler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 09:30:03
Message: <3C6BC80E.9030609@webcon.de>
Tom Melly wrote:

> "Hermann Voßeler" <h.v### [at] webconde> wrote in message
> news:3C6### [at] webconde...
> 
> <snip>
> 
> Might be worth implementing if only to see Ken turning in his grave.... ("But
> he's not dead", "No, but this will kill him")
> 
> I don't like it, although I can see the attraction. It strikes me as mixing up
> style and content - which is exactly the confusion that got html/browsers in to
> such trouble....
> 

the point is, it makes code much more readable, because it reduces
"syntactic noise".

Programmers usualy indent their code carefuly in order to make the
structure clear to the human reader. Only those dumb compilers don't
get right what everyone can see clearly :-;
You know, the "dangling else"-problem...

Thus, its not mixing up style and content.
With this rule, indentation is no longer a question of style but
caries valid information content, that can be exploited by the 
compiler to resolve ambiguities.


Post a reply to this message

From: Warp
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 09:45:47
Message: <3c6bcd9b@news.povray.org>
Hermann Voßeler <h.v### [at] webconde> wrote:
: the point is, it makes code much more readable, because it reduces
: "syntactic noise".

: Programmers usualy indent their code carefuly in order to make the
: structure clear to the human reader. Only those dumb compilers don't
: get right what everyone can see clearly :-;
: You know, the "dangling else"-problem...

  The ability of making obfuscated POV-Ray signatures is a must. Any change
in the syntax which makes obfuscation or reducing a piece of code more
difficult is not good.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 09:50:33
Message: <3c6bceb9@news.povray.org>
Nekar Xenos <jpr### [at] citywalkcoza> wrote:
: I would rather just do away with the #'s.

  It's true that getting rid of most #'s would do more good than harm.
The reason for the #-commands is that they initially worked like the
preprocessor commands in C, that is, they just #included something and
#declared some constants, like you can do in the C preprocessor.
  However, as time passed, the #-commands developed into a full scripting
language which no more resemble a preprocessor but are direct script commands.

  Thus it might be a good idea to keep the #'s in the commands which are
clearly "preprocessor" commands and remove them (or better make them optional)
in scripting language commands (control flow commands, variable assignments
and so on).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 11:45:04
Message: <chrishuff-F21221.11444514022002@netplex.aussie.org>
In article <3C6### [at] webconde>,
 Hermann Voßeler <h.v### [at] webconde> wrote:

> they use a indentation rule to figure out when a statement belongs to 
> a block. As long as you indent new lines more than the line that 
> started the block, the compiler knows you want to stay within that 
> block. As soon as you indent lesser, it adds a implicit "}".
> Works great.

I've never liked the idea of a language that relied on indentation and 
white space as controlling elements. Some kind of visible block 
delimiter is much better, and "{}" are already used in many languages, 
so people are familiar with them. Explicit begin and end keywords are 
also used in some languages, these take more typing and make more 
cluttered code in my opinion, but are better than whitespace.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 11:47:11
Message: <chrishuff-921D76.11465314022002@netplex.aussie.org>
In article <3C6### [at] webconde>,
 Hermann Voßeler <h.v### [at] webconde> wrote:

> I didn't mention that, but in haskell you are not bound to use
> the layout-rule. You can as well go on and type as many {{{braces}}}
> as you like. Only if you open a block without using a brace, the
> compiler can figure out by indentation.

Aack! That would be worse than indentation-only...I can imagine files 
with a horrible mix of indentation and brackets, users being unsure of 
where they can put brackets, bugs because of accidental mixing of 
brackets and indentation, etc...it would also be harder to read.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 11:57:01
Message: <3c6bec5c@news.povray.org>
How would it handle something like this:

#if(Fast)
  box
    -1,1
#else
  superellipsoid
    <.1,1>
#end
    pigment
      rgb 1

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From:
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 14 Feb 2002 12:08:37
Message: <l5rn6uk21jguit6qqj7v4bkfa6q391ra6a@4ax.com>
On 14 Feb 2002 11:57:01 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  How would it handle something like this:

I wonder how it could handle this in intendation mode:

#macro o()object{#end
#macro b()box{#end
#macro f()function{#end
#macro p()pigment{color#end
#local C=f()pattern{o()b()1 2}}}}
#local B=b()C(1.5,1.5,1.5)2p()1}}
o()B}

:-)

ABX


Post a reply to this message

From: Hermann Voßeler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 15 Feb 2002 15:31:15
Message: <3C6D6E38.6070407@webcon.de>
Christopher James Huff wrote:

 >
 > I've never liked the idea of a language that relied on indentation
 > and white space as controlling elements. Some kind of visible block
 > delimiter is much better, and "{}" are already used in many
 > languages, so people are familiar with them. Explicit begin and end
 > keywords are also used in some languages, these take more typing
 > and make more cluttered code in my opinion, but are better than
 > whitespace.
 >


Indeed, I also where rather sceptic, as I lerned haskell some years
ago. I didn't like the idea and thought it would cause problems all
the time. It was a big surprise how good it worked. Of course, the
braces are more of a problem in a functional language with all the
function-style-if-then-else, alternativ clauses and pattern matching
definitions.

Maybee, one reason it works so well there is, that haskell has a
rather elaborated type system and thus the compiler can generate very
specific and precise error messages. Morover the layout rule is an
optional feature and activated on a per-statement-base, when the
opening brace is missing. This, btw, makes implementing the parser
rather a tough job, because there has to be a sort of "talkback"
channel between parser and tokenizer.


Post a reply to this message

From: Hermann Voßeler
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 15 Feb 2002 15:31:21
Message: <3C6D6E3E.1090606@webcon.de>
...if macros are defined strictly as mere copy-and-paste
operations, then there will be no problem as long as the
compiler sees valid code after macro expansion. (One of
the haskell compilers indeed uses the c preprocessor to
do such things)

Warp wrote:

 >   How would it handle something like this:
 >
 > #if(Fast)
 >   box
 >     -1,1
 > #else
 >   superellipsoid
 >     <.1,1>
 > #end
 >     pigment
 >       rgb 1
 >

W³odzimierz ABX Skiba wrote:

> I wonder how it could handle this in intendation mode:
> #macro o()object{#end
> #macro b()box{#end
> #macro f()function{#end
> #macro p()pigment{color#end
> #local C=f()pattern{o()b()1 2}}}}
> #local B=b()C(1.5,1.5,1.5)2p()1}}
> o()B}
> 
> :-)
> 
> ABX
>


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 15 Feb 2002 15:58:01
Message: <3c6d7659@news.povray.org>
In article <3C6### [at] webconde> , Hermann Voßeler 
<h.v### [at] webconde>  wrote:

> do you know the haskell (funcitonal) programming language?

Why do people always have to mention these "strange" languages? :-)

If I hadn't had to try Haskell, maybe I would be more favorable of its (I have
to admit not too bad) implementation of some old ideas.  Nevertheless, like
all these odd languages, it is not even close to the smooth* learning curve of
the traditional programming languages (which have proven they are capable of
more than a few hundred lines of nice examples how compact they can solve a
problem, which seems to be the common reason to invent a new language) or some
even more high-level languages specifically designed for end user programming.

After all, for someone with no programming experience the elegance an expert
can find in a language hardly matters.  What is far more important is a close
to zero learning curve and very good feedback (and i.e. the common Haskell
error messages are more than cryptic IMHO, even compared to POV-Ray).

    Thorsten

* For various reasons, one being that for "popular" languages there are
usually very good books, while for less popular languages there are no or very
few mostly useless books.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 15 Feb 2002 16:14:41
Message: <3c6d7a41@news.povray.org>
In article <chr### [at] netplexaussieorg> , Christopher
James Huff <chr### [at] maccom>  wrote:

> Aack! That would be worse than indentation-only...I can imagine files
> with a horrible mix of indentation and brackets, users being unsure of
> where they can put brackets, bugs because of accidental mixing of
> brackets and indentation, etc...it would also be harder to read.

And even worse, these languages are just as open to language feature abuse as
the languages they try to improve on.

I am sure the below gets screwed up by posting here (because of wrapping
lines), but I think it gives everybody an idea of a pointless use of a
language.  Before anybody looks at the code, I should point out that I only
had about 1.5 hours and zero motivation to do the below as a homework
assignment.  I did not read the manual, I simply took some examples and cooked
something out of what I had with minimal effort.  This is why my tree insert
function is the most brain-dead and least efficient possible implementation,
thus providing a perfect example how to abuse this supposedly elegant language
... not to mention, even in C the code would not only be shorter but IMO also
more understandable when just looking at it.  Not to mention C++ and the STL,
which would reduce the code below to next to zero work!  And I can think of
much shorter Lisp implementations of such a trivial thing as well.

-- Set 2

-- Binary Tree Data Structure

data Mtree middle = Null | Leaf middle | Fork (Mtree middle) middle (Mtree
middle)
                    deriving (Show)

-- Utility Functions

-- Function:    list2tree
-- Parameters:  tree, list
-- Theory of operation:
--   Given an empty tree and an ordered list, this function will build
--   a valid tree out it.  The tree has only right nodes in exactly the
--   same order as they appear in the list.  Note that because the tree
--   is constructed recursively the list has to be reversed in order to
--   get a valid binary tree.  Of course, this tree is the worst of all
--   possible trees, but there is no question it is valid.

list2tree Null [] = Null
list2tree (Leaf middle) [] = (Leaf middle)
list2tree (Fork left middle right) [] = (Fork left middle right)
list2tree Null (x:xs) = list2tree (Leaf x) (reverse xs)
list2tree (Leaf middle) (x:xs) = list2tree (Fork Null middle (Leaf x)) xs
list2tree (Fork ignore middle right) (x:xs) = list2tree (Fork Null middle
(Fork Null x right)) xs


-- Function:    ordlistinsert
-- Parameters:  element, list
-- Theory of operation:
--   Given an element and an ordered list, this function will insert the
--   at the appropriate position based on the order defined by the less
--   than comparison operator.

ordlistinsert element [] = []
ordlistinsert element (x:xs) | x < element = [x] ++ (listinsert element xs)
                             | otherwise = [element] ++ [x] ++ xs


-- Assignment Set 2

-- Set 2.1

-- Function:    tflatten
-- Parameters:  Mtree
-- Theory of operation:
--   Given a tree, this function constructs a list containing the nodes
--   inorder as they appear in the tree from left to right, depthest node
--   first.

tflatten Null = []
tflatten (Leaf middle) = [middle]
tflatten (Fork left middle right) = tflatten (left ++ [middle] ++ tflatten)
right


-- Set 2.2

-- Function:    depth
-- Parameters:  Mtree
-- Theory of operation:
--   Walks through the whole tree recursivly and always returns the
--   greatest depth of a subtree.

depth Null = 0
depth (Leaf ignore) = 0
depth (Fork left ignore right) | (depth left) >= (depth right) = (depth left)
+ 1
                               | otherwise = (depth right) + 1


-- Set 2.3

-- Function:    insert
-- Parameters:  Mtree, element
-- Theory of operation:
--   This is the simplest possible implementation based on the previously
--   defined functions.  It uses the tflatten, list2tree and ordlistinsert
--   functions to get a list of the tree nodes, then inserts the given
--   element and turns the list back into a tree.  Since a recursive tree
--   insert function (provided as function betterinsert) does not create
--   a perfectly balanced tree, a banaced tree is obviously not part of the
--   assignment and the given tree is valid because the assignment required
--   only that the "mathematical ordering for integers and the lexiographical
--   order for strings".  This function does exactly that, and based on it
--   it is easy to write a function to return a balanced tree.

insert Null x = Leaf x
insert (Leaf middle) x | x < middle = Fork (Leaf x) middle Null
                       | otherwise = Fork Null middle (Leaf x)
insert (Fork left middle right) x = list2tree Null (ordlistinsert x ((tflatten
left) ++ [middle] ++ (tflatten right)))


-- Function:    betterinsert
-- Parameters:  Mtree, element
-- Theory of operation:
--   Recursive version of insert that keeps the tree in shape.  The new
--   node is inserted and the rest of the tree is moved to a leaf, either
--   the left or the right one, depending on the node compared to the
--   element to insert.

betterinsert Null x = (Leaf x)
betterinsert (Leaf middle) x | x < middle = Fork (Leaf x) middle (Null)
                             | otherwise = Fork (Null) middle (Leaf x)
betterinsert (Fork left middle right) x | x < middle = Fork (betterinsert left
x) middle right
                                        | otherwise = Fork left middle
(betterinsert right x)


-- Set 2.4

-- Function:    remove
-- Parameters:  Mtree, element
-- Theory of operation:
--   The function works analog to insert.  Since this function satisfies
--   requirements set by the assignment, I will not waste my time with the
--   recursive implementation of this function.

remove Null x = Null
remove (Leaf middle) x | middle == x = Null
                       | otherwise = (Leaf middle)
remove (Fork left middle right) x | middle == x = list2tree Null (dropWhile (x
==) ((tflatten left) ++ (tflatten right)))
                                  | otherwise = list2tree Null (dropWhile (x
==) ((tflatten left) ++ [middle] ++ (tflatten right)))


Post a reply to this message

From: Warp
Subject: Re: Possible POV Object Scheme (was Re: Pov 4.00 question)
Date: 15 Feb 2002 17:17:52
Message: <3c6d8910@news.povray.org>
Hermann Voßeler <h.v### [at] webconde> wrote:
: ...if macros are defined strictly as mere copy-and-paste
: operations

  But they aren't.

  This:

#macro A()
  #local Val = 2;
#end

#local Val = 1;
A()
// Val is 1 at this point

is *not* what a copy-and-paste macro scheme would do:

#local Val = 1;
#local Val = 2;
// Val is 2 at this point

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

<<< Previous 50 Messages Goto Initial 50 Messages

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