POV-Ray : Newsgroups : povray.general : #declare Server Time
11 Sep 2024 03:29:03 EDT (-0400)
  #declare (Message 6 to 15 of 25)  
<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>
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

From: Warp
Subject: Re: #declare
Date: 19 Oct 2002 17:33:03
Message: <3db1cf8f@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
>   20 + $x         will result in 120 (x is used like number)

  FYI it didn't work that way in MegaPov.

-- 
#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:54:03
Message: <Xns92ACF2DBC455Draf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3db1cf8f@news.povray.org

> Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
>>   20 + $x         will result in 120 (x is used like number)
>   FYI it didn't work that way in MegaPov.

Yes - it didn't. Do You think it would be a good idea to allow such 
behaviour ?

-- 
#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: Christopher James Huff
Subject: Re: #declare
Date: 19 Oct 2002 20:07:40
Message: <3db1f3cc@news.povray.org>
"Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote in message
news:Xns### [at] 204213191226...
> 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 :

That's not useful, in fact it sounds like a terrible idea, and isn't any
more possible with that syntax anyway.


Post a reply to this message

From: Christopher James Huff
Subject: Re: #declare
Date: 19 Oct 2002 20:11:15
Message: <3db1f4a3@news.povray.org>
"Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote in message
news:Xns### [at] 204213191226...
> 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.

Use upper case in your variable names. Upper case words will never be
reserved.


> 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)

You're joking, right? You *like* that?


Post a reply to this message

From: hughes, b 
Subject: Re: #declare
Date: 19 Oct 2002 20:49:51
Message: <3db1fdaf$1@news.povray.org>
"Christopher James Huff" <cja### [at] earthlinknet> wrote in message
news:3db1f4a3@news.povray.org...
> "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote in message
> news:Xns### [at] 204213191226...
> > I.e someone will write script, with variables like say :
> >   a, b, c, speed, displacment, size
>
> Use upper case in your variable names. Upper case words will never be
> reserved.

Would it be conceivable that a future POV-Ray could tag any and all
user-defined identifiers, regardless of case, as a non-keyword? It's not
always compulsory to use upper case letters so it can seem okay. In fact,
people have often complained they couldn't use a number as the first
character either.

> > 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)
>
> You're joking, right? You *like* that?

That would be weird to me.


Post a reply to this message

<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>

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