POV-Ray : Newsgroups : povray.general : Problem with Parse_String and #ifndef Server Time
4 Aug 2024 04:17:55 EDT (-0400)
  Problem with Parse_String and #ifndef (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Thorsten Froehlich
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 13:18:16
Message: <3f5f5cd8$1@news.povray.org>
In article <3f5f4f76$1@news.povray.org> , Florian Brucker 
<tor### [at] torfboldcom>  wrote:

> I understand this from the parser's point of view - normaly, opening
> brackets inside #ifndef() do not make sense, as identifiers aren't
> allowed to contain brackets. In the case of Parse_String(), however,
> it makes sense.

This isn't the parsers problem, it is your scene.  You simply do not
generate a valid scene with what you do.  This should be clear from the
specification of #ifndef (taking only a single identifier).

However, this isn't all.  There is a second misconception.  What you expect
is #macros to behave like macros, not functions.  However, if you read the
chapter in the documentation which explains the difference between the
POV-Ray #macro and what most people commonly expect from macros (and how
macros return something), you will notice that what you do cannot work as
expected.

Even worse, there is a third roadblock in your code, which is that a #macro
name can also be checked with an #ifndef.  And actually this is what the
parser catches first and reports an error for.  nevertheless, the first two
problems would persist even if this would be accepted by the parser.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Warp
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 13:45:26
Message: <3f5f6336@news.povray.org>
It would be nice if the string parsing was an internal command which
could be used anywhere.
  I suppose #parse would be a good name. This way you could do things like:

#declare #parse(concat(name1, name2)) = 5;

  That is, the parser would take the string given as parameter to #parse
and parse its contents as if it was just plain text appearing at that place
in the file. This would certainly be handy for many things.

  (OTOH it accentuates the importance of I/O restrictions because it would
allow making extremely obfuscated SDL code.)

  I think one important feature of this #parse command that differentiates
it from other commands is that it should be possible to appear *anywhere*
in the code. Even though this is not strictly indispensable, it would
certainly make it more useful.
  That is for example this:

#de#parse("cl")are ab#parse("cde")fg = 5;

would be effectively the same thing as:

#declare abcdefg = 5;

  I don't know if this behaviour would be easy to implement in the current
parser, but just an idea...

-- 
#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: Thorsten Froehlich
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 13:50:46
Message: <3f5f6476@news.povray.org>
In article <3f5f6336@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   That is for example this:
>
> #de#parse("cl")are ab#parse("cde")fg = 5;
>
> would be effectively the same thing as:
>
> #declare abcdefg = 5;
>
>   I don't know if this behaviour would be easy to implement in the current
> parser, but just an idea...

Aren't *you* the one who usually argues for well structured code? ;-) ;-)

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Warp
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 16:01:12
Message: <3f5f8308@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Aren't *you* the one who usually argues for well structured code? ;-) ;-)

  In C++ yes, but the POV-Ray SDL is a hacker language. :P

-- 
#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: Jim Charter
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 16:33:11
Message: <3f5f8a87$1@news.povray.org>
Warp wrote:
> Thorsten Froehlich <tho### [at] trfde> wrote:
> 
>>Aren't *you* the one who usually argues for well structured code? ;-) ;-)
> 
> 
>   In C++ yes, but the POV-Ray SDL is a hacker language. :P
> 
Do you mean a language for 'hacks', or a language for 'hackers'?


Post a reply to this message

From: Warp
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 17:23:50
Message: <3f5f9666@news.povray.org>
Jim Charter <jrc### [at] msncom> wrote:
> >   In C++ yes, but the POV-Ray SDL is a hacker language. :P
> > 
> Do you mean a language for 'hacks', or a language for 'hackers'?

  Mainly I meant a language for hackers. You know, that type of language
which you can use to make marvelous things with an incredibly short piece
of code... which is also so obfuscated you don't understand it at all... :P

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 18:02:15
Message: <3f5f9f67$1@news.povray.org>
> Thanks Tim!
>
> Greetings,
> Florian

You're welcome. I figured this one pretty
fast because I had similiar ideas about dynamic
texture/array/object generation some months
ago, and gave thought to those issues at
that time. And seeing your code, it was
rather simple to just write my initial thoughts
about it... :-)

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de


> Hi Tim!
>
> > You've got to experiment. Perhaps writing the entire
> > #ifndef () ... #debug ".." #end
> > to disc and #including that.
> That did the job!
>
> if anyone is interested, here's the code:
>
> <code>
> #include "strings.inc"
>
> #declare TestIdent = 1;
>
> #macro IFDEF2(Name)
> #declare TEMPDEF__ = 0;
>
> Parse_String(concat(
> "#ifdef(",Name,")
> #declare TEMPDEF__=1;
> #end"
> ))
>
> (TEMPDEF__)
> #end
>
> #if (IFDEF2("TestIdent"))
> #debug "defined\n"
> #else
> #debug "nope\n"
> #end
> </code>
>
> result: defined
>
> Thanks Tim!
>
> Greetings,
> Florian
> -- 
> //=================[web: http://www.torfbold.com]==================\\
> #local a=-5;#while(a<5)sphere{<sin(a*pi)*5a*10pow(a,5)*.01>sin(a*a*a*
> .1)+1pigment{rgb 9*z}}#local a=a+.01;#end camera{look_at-y*10location
> <8,-3,-8>*10}// [www.povray.org]     [www.imp.org]     [www.irtc.org]
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01.09.2003


Post a reply to this message

From: Christopher James Huff
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 21:35:38
Message: <cjameshuff-987A4F.21354710092003@netplex.aussie.org>
In article <3f5f6476@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> In article <3f5f6336@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:
> 
> > #de#parse("cl")are ab#parse("cde")fg = 5;
> 
> Aren't *you* the one who usually argues for well structured code? ;-) ;-)

Aren't you forgetting who started the scrambled signature craze?

-- 
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: Ken
Subject: Re: Problem with Parse_String and #ifndef
Date: 10 Sep 2003 21:46:01
Message: <3F5FD3A4.FCFB328A@pacbell.net>
Christopher James Huff wrote:
> 
> In article <3f5f6476@news.povray.org>,
>  "Thorsten Froehlich" <tho### [at] trfde> wrote:
> 
> > In article <3f5f6336@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:
> >
> > > #de#parse("cl")are ab#parse("cde")fg = 5;
> >
> > Aren't *you* the one who usually argues for well structured code? ;-) ;-)
> 
> Aren't you forgetting who started the scrambled signature craze?

I haven't (in case he conveniently forgets) and would be more than
happy to name names.

-- 
Ken Tyler


Post a reply to this message

From: Warp
Subject: Re: Problem with Parse_String and #ifndef
Date: 11 Sep 2003 08:10:50
Message: <3f60664a@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
> > Aren't you forgetting who started the scrambled signature craze?

> I haven't (in case he conveniently forgets) and would be more than
> happy to name names.

  But I'm proud of that. :)

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

<<< Previous 5 Messages Goto Initial 10 Messages

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