POV-Ray : Newsgroups : povray.general : #declare Server Time
18 Nov 2024 03:16:50 EST (-0500)
  #declare (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Rafal 'Raf256' Maj
Subject: #declare
Date: 18 Oct 2002 07:42:48
Message: <Xns92AB8B3B44ABDraf256com@204.213.191.226>
Hello,
#declare aaa = ... ;
is probably most common exprssion in POV while using it as srcipt language, 
why the idea introduced in MegaPov ( to use $aaa=...; ) was droped / not 
included into officila Pov 3.5 ?

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: #declare
Date: 18 Oct 2002 08:05:11
Message: <3daff8f7@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> Hello,
> #declare aaa = ... ;
> is probably most common exprssion in POV while using it as srcipt language, 
> why the idea introduced in MegaPov ( to use $aaa=...; ) was droped / not 
> included into officila Pov 3.5 ?

  I think it had some ambiguity problems in MegaPov, IIRC. Don't remember
the details...

-- 
#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: ingo
Subject: Re: #declare
Date: 18 Oct 2002 09:16:09
Message: <Xns92AB9C246D97Cseed7@povray.org>
in news:Xns### [at] 204213191226 Rafal 'Raf256' Maj
wrote: 

> #declare aaa = ... ;
> is probably most common exprssion in POV while using it as srcipt
> language, why the idea introduced in MegaPov ( to use $aaa=...; ) was
> droped / not included into officila Pov 3.5 ?
> 

Not an awnser to your question, but a question triggerd by it; Why is 
there a #declare at all?

aaa="anythingyouwantittobe"

Ingo

p.s. I have no problem with #declare and think $... is unaesthetic.


Post a reply to this message

From: Christopher James Huff
Subject: Re: #declare
Date: 18 Oct 2002 10:35:44
Message: <chrishuff-88DD56.10304618102002@netplex.aussie.org>
In article <Xns### [at] 204213191226>,
 "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:

> Hello,
> #declare aaa = ... ;
> is probably most common exprssion in POV while using it as srcipt language, 
> why the idea introduced in MegaPov ( to use $aaa=...; ) was droped / not 
> included into officila Pov 3.5 ?

1: It's ugly.
2: It's harder to read.
3: It doesn't fit in with the rest of the syntax.
4: It didn't work right. I don't know what exactly the problems were (I 
never used the patch), but there were problems with it.

I don't like the current syntax either, though...take this code for 
example:

#declare myCounter = 0;
#while(myCounter < 10)
    Code
    Code
    Code
    Code
    ...
    #declare myCountr = myCounter + 1;
#end

That's an infinite loop from a simple typo, because POV doesn't know the 
difference between modifying a variable and making a new one.

I made a patch that allowed this:
#declare myCounter = 0;
#while(myCounter < 10)
    #set myCountr = myCounter + 1;
#end

#set will modify a variable, but it will give an error if it doesn't 
already exist, something like "attempt to set nonexistant variable". It 
is also less typing, and makes less code to modify if you decide to put 
things in a macro...it works with local variables just fine, so you have 
fewer #declares to turn into #locals.

This was designed to fit in with the current syntax, though. I'd rather 
redesign the language and use something more like:

def myCounter = 0;
while(myCounter < 10) {
    myCounter += 1;
}

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Francois Labreque
Subject: Re: #declare
Date: 18 Oct 2002 22:12:08
Message: <3DB0BE8C.3040102@videotron.ca>
Christopher James Huff wrote:


> redesign the language and use something more like:
> 
> def myCounter = 0;
> while(myCounter < 10) {
>     myCounter += 1;
> }

Having +=, -=, etc... would certainly be nice.  Even with #declare, if 
it issued and error for uninitialized variables, for example:

#declare myCounter = 0;
#while( myCounter < 10 ) {
     #declare myCountr += 1;
}

The parser could choke and issue an error because it doesn't know what 
the initial value of "myCountr" is.

-- 
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/*    flabreque    */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/*        @        */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/*   videotron.ca  */}camera{orthographic location<6,1.25,-6>look_at a }


Post a reply to this message

From: Warp
Subject: Re: #declare
Date: 19 Oct 2002 15:52:01
Message: <3db1b7e0@news.povray.org>
Another good thing about the operator-and-assignment is that it can
save writing and make parsing faster.
  For example, consider this:

#declare Table[Index1*2+Offset1][Index2*2+Offset2] =
Table[Index1*2+Offset1][Index2*2+Offset2] + 1;

vs:

#declare Table[Index1*2+Offset1][Index2*2+Offset2] += 1;

-- 
#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: Rafal 'Raf256' Maj
Subject: Re: #declare
Date: 19 Oct 2002 15:54:43
Message: <Xns92ACDEA2518DEraf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3db1b7e0@news.povray.org

#declare Table[Index1*2+Offset1][Index2*2+Offset2] =
Table[Index1*2+Offset1][Index2*2+Offset2] + 1; 

$Table[$Index1*2+$Offset1][$Index2*2+$Offset2]+=1;

syntax $var_name ihas one greate advantage :

$sphere = 10;
$ior = 50;

You can use variable names that are reserved words. This is in fact VERY usefull,
in stuff like :

// from #version 3.1
#declare dispersion = 5.0;  

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: #declare
Date: 19 Oct 2002 16:16:16
Message: <3db1bd8f$6@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> syntax $var_name ihas one greate advantage :

> $sphere = 10;
> $ior = 50;

> You can use variable names that are reserved words.

  How do you expect to use those variable names?

-- 
#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: Rafal 'Raf256' Maj
Subject: Re: #declare
Date: 19 Oct 2002 17:15:23
Message: <Xns92ACEC4D167Araf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3db1bd8f$6@news.povray.org

I.e someone will write script, with variables like say :
  a, b, c, speed, displacment, size
It will work fine, until in say POV 4.0 displacment will became a 
reserved word and stop this script from working.

I like very much PHP style - where every variable name starts with '$'.

What do You think about allowing, as PHP, syntax with variant types, 
say :
$x = 100;
  "foo"+$x+"bar"  will result in "foo100bar" (x is used like string)
and :
  20 + $x         will result in 120 (x is used like number)

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Johannes Dahlstrom
Subject: Re: #declare
Date: 19 Oct 2002 17:31:06
Message: <3db1cf19@news.povray.org>
Rafal 'Raf256' Maj wrote:

> I.e someone will write script, with variables like say :
>   a, b, c, speed, displacment, size
> It will work fine, until in say POV 4.0 displacment will became a
> reserved word and stop this script from working.

Just do as the docs suggest and use at least one capital letter in your 
variable names.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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