POV-Ray : Newsgroups : povray.pov4.discussion.general : Identifier declaration consistent with other languages Server Time
15 Oct 2026 03:11:33 EDT (-0400)
  Identifier declaration consistent with other languages (Message 1 to 18 of 18)  
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

From: Dan Connelly
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 08:39:10
Message: <491c2dfe@news.povray.org>
Chambers wrote:
> I am categorically against whitespace having meaning.


If you want python-like syntax, just embed POV in python.  Or if you want Perl-like
syntax, embed in Perl.  Personally, I think python is more manageable, although I'm
far more adept at perl.

If an independent syntax is to be maintained, it's best kept simple at the expense of
power.

Dan


Post a reply to this message

From: Dan Connelly
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 08:40:17
Message: <491c2e41$1@news.povray.org>
Dan Connelly wrote:
> Chambers wrote:
>> I am categorically against whitespace having meaning.
> 
> 
> If you want python-like syntax, just embed POV in python.

I had that backwards.... it's "embed python in POV":
http://www.linuxjournal.com/article/8497


Post a reply to this message

From: SharkD
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 09:45:00
Message: <web.491c3ce0909e697887ff2bed0@news.povray.org>
Dan Connelly <djc### [at] yahoocom> wrote:
> Chambers wrote:
> > I am categorically against whitespace having meaning.
>
>
> If you want python-like syntax, just embed POV in python.  Or if you want Perl-like
syntax, embed in Perl.  Personall
y, I think python is more manageable, although I'm far more adept at perl.
>
> If an independent syntax is to be maintained, it's best kept simple at the expense
of power.
>
> Dan

Lua is another option. I like it better than Perl or Python.

-Mike


Post a reply to this message

From: Warp
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 10:20:55
Message: <491c45d7@news.povray.org>
SharkD <nomail@nomail> wrote:
> Lua is another option. I like it better than Perl or Python.

  AngelScript is more tempting than lua, python or perl because it has much
closer resemblance to the language POV-Ray itself is written in. It should
also be as easy to embed as lua.

-- 
                                                          - Warp


Post a reply to this message

From: SharkD
Subject: Re: Identifier declaration consistent with other languages
Date: 13 Nov 2008 20:35:00
Message: <web.491cd4ff909e6978849303c80@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   AngelScript is more tempting than lua, python or perl because it has much
> closer resemblance to the language POV-Ray itself is written in. It should
> also be as easy to embed as lua.
>
> --
>                                                           - Warp

Never heard of AngelScript. :)

-Mike


Post a reply to this message

From: Warp
Subject: Re: Identifier declaration consistent with other languages
Date: 14 Nov 2008 11:10:07
Message: <491da2df@news.povray.org>
SharkD <nomail@nomail> wrote:
> Warp <war### [at] tagpovrayorg> wrote:
> >   AngelScript is more tempting than lua, python or perl because it has much
> > closer resemblance to the language POV-Ray itself is written in. It should
> > also be as easy to embed as lua.

> Never heard of AngelScript. :)

  Google is your friend.

-- 
                                                          - Warp


Post a reply to this message

From: SharkD
Subject: Re: Identifier declaration consistent with other languages
Date: 20 Nov 2008 00:05:00
Message: <web.4924ef8c909e6978ae013790@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> SharkD <nomail@nomail> wrote:
> > Warp <war### [at] tagpovrayorg> wrote:
> > >   AngelScript is more tempting than lua, python or perl because it has much
> > > closer resemblance to the language POV-Ray itself is written in. It should
> > > also be as easy to embed as lua.
>
> > Never heard of AngelScript. :)
>
>   Google is your friend.
>
> --
>                                                           - Warp

What's important, IMO, is that scene files be easy to parse using an external
editor. XML is a popular choice, and many parsers already exist; however, my
personal preference would be the use of simple and compact hash arrays.

-Mike


Post a reply to this message

From: Warp
Subject: Re: Identifier declaration consistent with other languages
Date: 20 Nov 2008 07:10:24
Message: <492553b0@news.povray.org>
SharkD <nomail@nomail> wrote:
> XML is a popular choice

  A popular choice for what? Certainly not for an embedded scripting language.
(XML is *not* a scripting language at all.)

-- 
                                                          - Warp


Post a reply to this message

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