POV-Ray : Newsgroups : povray.pov4.discussion.general : POV-Ray 4 SDL: Some concrete proposal : Re: POV-Ray 4 SDL: Some concrete proposal Server Time
2 May 2024 04:29:42 EDT (-0400)
  Re: POV-Ray 4 SDL: Some concrete proposal  
From: ingo
Date: 24 Apr 2009 15:08:15
Message: <Xns9BF7D700B958Eseed7@news.povray.org>
in news:web.49e39942d93ad1dd2dae03a10@news.povray.org clipka wrote:

> I'll try to describe what I have currently in mind. But first let me
> present to you a kind of "hello world" scene written in that
> language: 
> 
> 
> include "colors.inc";

include colors
 
> SphereCenter = <0,1,0>;

Spherecenter = <0,1,0>
Sphereradius = 1

> sphere {
>   center: SphereCenter;
>   radius: 1 as SphereRadius;
>   texture {
>     pigment { color: #<1,0,0> }
>   };
> } as MainSphere;

MainSphere = sphere {
  center = SphereCentre,
  radius = SphereRadius,
  texture {
    color = <1,0,0> 
    //(if we need more than a 3-vector define the kind rgbf<1,0,0,1>)
  }
}

... the as SphereRadius is confusing and obfusicating.

read http://docs.python.org/tutorial/controlflow.html#defining-
functions and espacialy the next section.

the alternative of the above Mainsphere thus should be:

MainSphere = sphere {
  SphereCentre,
  SphereRadius,
  texture {
    color = <1,0,0> 
    //(if we need more than a 3-vector define the kind rgbf<1,0,0,1>)
  }
}
... kind of exactly the same as we have now :)

taking it a bit further, the way to declare macros should be exactly as 
done in Python, but then in SDL:

macro Sphere(spherecentre=<0,0,0>,sphereradius=1, ...etc)

so using the Sphere macro in the scene looks exactly like using the 
built in sphere.

Now Warp will of course argue that this new Sphere thing should not be 
a macro but a class that inherits from the "objects" class so all the 
texture etc. stuff is readily available and he's right.

class Sphere(object){
  spherecentre=<0,0,0>
  sphereradius=1
  and all kinds of clever code to generate the object
}
 
 
> modify MainSphere {
>   radius: 0.9;
> };

MainSphere.radius=0.9

MainSphere{radius=0.9} could be mistaken for the declaration of a new 
sphere with radius, using the default centre and texture.

I realy like Python, but don't use it as an SDL but steal as much 
possible from it and use it in a sytax as close as possible tot the 
current SDL as possible and read:

The Zen of Python

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do 
it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!


Ingo


Post a reply to this message

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