POV-Ray : Newsgroups : povray.pov4.discussion.general : Identifier declaration consistent with other languages Server Time
21 Dec 2024 13:27:25 EST (-0500)
  Identifier declaration consistent with other languages (Message 1 to 10 of 18)  
Goto Latest 10 Messages Next 8 Messages >>>
From: Chambers
Subject: Identifier declaration consistent with other languages
Date: 20 Jul 2008 13:56:59
Message: <48837c6b$1@news.povray.org>
Instead of

#declare myobj = object {

Why not use

object myobj {

It's more consistent with pretty much every other programming language 
since BASIC dropped the "LET" keyword.

...Chambers


Post a reply to this message

From: Warp
Subject: Re: Identifier declaration consistent with other languages
Date: 20 Jul 2008 17:59:46
Message: <4883b551@news.povray.org>
Chambers <ben### [at] pacificwebguycom> wrote:
> Instead of

> #declare myobj = object {

> Why not use

> object myobj {

  The intention is to redesign the SDL for pov4 anyways. What we need is
a good overall design rather than just individual bits.

-- 
                                                          - Warp


Post a reply to this message

From: Allen
Subject: Re: Identifier declaration consistent with other languages
Date: 5 Nov 2008 15:25:00
Message: <web.4911ffd2909e69788f162dfb0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Chambers <ben### [at] pacificwebguycom> wrote:
> > Instead of
>
> > #declare myobj = object {
>
> > Why not use
>
> > object myobj {
>
>   The intention is to redesign the SDL for pov4 anyways. What we need is
> a good overall design rather than just individual bits.
>
> --
>                                                           - Warp

I'd like to see more powerful scripting support as well.  I use Python
frequently to generate POV-ray code.

An a syntax change:

Instead of

#declare count = 10
#declare pos = 0
#declare MyObject = union {
  #while(pos < count)
  circle {
    <0, 0, 5>, 0.5
    rotate <0, pos * 360 / count, 0>
    texture {
      pigment {
        #if(pos % 2 == 0)
          color White
        #else
          color Black
        #end
      }
    }
  }
  #declare pos = pos + 1
  #end
}

Why not simply have:

count = 10
MyObject = union {
  for(pos = 0, pos < count, pos = pos + 1) {
    circle {
      <0, 0, 5>, 0.5
      rotate <0, pos * 360 / count, 0>
      texture {
        pigment {
          if(pos % 2 == 0) {
            color White
          } else {
            color Black
          }
        }
      }
    }
  }
}


MyMacro = macro(p1, p2, p3) {
  /* Macro body */
}

MyMacro(x, y, z)


Post a reply to this message

From: Allen
Subject: Re: Identifier declaration consistent with other languages
Date: 5 Nov 2008 16:15:01
Message: <web.49120bff909e69788f162dfb0@news.povray.org>
Other ideas:

Currently there is a difference between declaring an item and using it:

// Declare a circle
#declare MyCircle = circle {
  ...
}

// Use a circle
circle {
  ...
}

// or
object {
  MyCirlce
  ...
}

When you use the item you can't give its 'instance' a name however.  In most
languages you can declare objects and create named instances of these objects.

// Declare an object (but don't use/create and instance of it)
circle MyCircle
{
}

texture MyTexture
{
  pigment
  {
    color Green
  }
}

// Create an unnamed instance of an unnamed object
circle
{
}

// create an unnamed instance of a named object
MyCircle
{
}

// Create a named instance of a named object
circle1 = MyCircle
{
  // overrides
}

circle2 = MyCircle
{
  scale circle1.radius

  texture { MyTexture }
}

circle3 = MyCircle
{
  <(circle2.x + circle1.x) / 2,
   (circle2.y + circle1.y) / 2,
   0>
}

Better yet why not have a full scripting built on top of an existing scripting
language (of course security may be an issue) such as Python, or AngelScript,
etc


Post a reply to this message

From: Warp
Subject: Re: Identifier declaration consistent with other languages
Date: 5 Nov 2008 16:31:36
Message: <491210b8@news.povray.org>
Allen <bri### [at] yahoocom> wrote:
> Why not simply have:

  Some could argue that this is why:

>           }
>         }
>       }
>     }
>   }
> }

-- 
                                                          - Warp


Post a reply to this message

From: Allen
Subject: Re: Identifier declaration consistent with other languages
Date: 6 Nov 2008 18:15:01
Message: <web.491379d8909e69788f162dfb0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Allen <bri### [at] yahoocom> wrote:
> > Why not simply have:
>
>   Some could argue that this is why:
>
> >           }
> >         }
> >       }
> >     }
> >   }
> > }
>
> --
>                                                           - Warp

Yes, but how is that any worse than something like:

          }
        #end
      }
    #end
  }
#end


Post a reply to this message

From: Allen
Subject: Re: Identifier declaration consistent with other languages
Date: 10 Nov 2008 02:40:00
Message: <web.4917e46c909e69788f162dfb0@news.povray.org>
Another way to do away with #end/{/} may be to adopt a Python-like blocking
mechanism where the indentation level affects the block.  Then a block as above
could simply be:

MyRing = union:
  for(x=0,x<10,x=x+1):
    circle:
      <...>
....


One problem I've heard from critics of this system is that most editors can't
automatically detect and create folds.


Post a reply to this message

From: Chambers
Subject: Re: Identifier declaration consistent with other languages
Date: 11 Nov 2008 13:48:46
Message: <6B674F3794A14536BD48AF8381DFCBB5@HomePC>
I am categorically against whitespace having meaning.

...Ben Chambers
www.pacificwebguy.com


> -----Original Message-----
> From: Allen [mailto:bri### [at] yahoocom]
> Posted At: Sunday, November 09, 2008 11:36 PM
> Posted To: povray.pov4.discussion.general
> Conversation: Identifier declaration consistent with other languages
> Subject: Re: Identifier declaration consistent with other languages
> 
> Another way to do away with #end/{/} may be to adopt a Python-like
> blocking
> mechanism where the indentation level affects the block.  Then a block
> as above
> could simply be:
> 
> MyRing = union:
>   for(x=0,x<10,x=x+1):
>     circle:
>       <...>
> ....
> 
> 
> One problem I've heard from critics of this system is that most
editors
> can't
> automatically detect and create folds.
>


Post a reply to this message

From: Kenneth
Subject: Re: Identifier declaration consistent with other languages
Date: 11 Nov 2008 18:00:01
Message: <web.491a0e1e909e697878dcad930@news.povray.org>
"Chambers" <ben### [at] pacificwebguycom> wrote:
> I am categorically against whitespace having meaning.
>

I tend to agree. It would, to my mind, create another level of difficulty in
trying to track down erroneous bits if code. Not being a programmer per se
(except with the POV SDL), I'm thinking that both the space bar and the tab
button would create identical(?) white spaces. Of course, that may be my naive
and uninformed notion. Please correct me if I'm wrong; I'm willing to learn!

Ken W.


Post a reply to this message

From: Allen
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 07:35:01
Message: <web.491c1e38909e69788f162dfb0@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> "Chambers" <ben### [at] pacificwebguycom> wrote:
> > I am categorically against whitespace having meaning.
> >
>
> I tend to agree. It would, to my mind, create another level of difficulty in
> trying to track down erroneous bits if code. Not being a programmer per se
> (except with the POV SDL), I'm thinking that both the space bar and the tab
> button would create identical(?) white spaces. Of course, that may be my naive
> and uninformed notion. Please correct me if I'm wrong; I'm willing to learn!
>
> Ken W.

I'm pretty certain that Python considers a tab character in the input to be
equal to 8 space characters.  It is really my only complaint with Python, in
all other ways I really enjoy Python.

With such code it is better not to mix tabs/spaces else visually you can't
really see where a block is at.  Nice thing about C/C++, braces can be anywhere
and statements are terminated with a semicolon so it can span multiple lines
anywhere.  Python can only span multiple lines with a line continuation or
inside of groups such as [], (), and {}


Invalid python:

list =
[
  1,
  2,
  3
]

Valid:

list = [
  1,
  2,
  3
]


Post a reply to this message

Goto Latest 10 Messages Next 8 Messages >>>

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