POV-Ray : Newsgroups : povray.general : POV crash with functions Server Time
16 Nov 2024 15:17:52 EST (-0500)
  POV crash with functions (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: JC (Exether)
Subject: POV crash with functions
Date: 10 Nov 2003 14:30:06
Message: <3fafe73e@news.povray.org>
I tried to post this message three times in P.bugreports and it didn't 
work, sorry if I'm multiposting.

So I wrote the following:


#macro F_Plane ()
   #local fn_p=function (x,y,z) { y };
   fn_p
//  function (x,y,z) { fn_p (x,y,z) }
#end

#local F1= F_Plane();

#declare fn_crash = function(x,y,z) { F1(x,y,z) }


and got a POV access violation (official Win32 POV (MegaPOV crashes 
too)). Commented code is a workaround.

I hope that helps,

JC


Post a reply to this message

From: Christoph Hormann
Subject: Re: POV crash with functions
Date: 10 Nov 2003 15:12:02
Message: <c08581-a4b.ln1@triton.imagico.de>
JC (Exether) wrote:
> I tried to post this message three times in P.bugreports and it didn't 
> work, sorry if I'm multiposting.

povray.bugreports is moderated, postings will only occur there if it is 
a confirmed bug.

> So I wrote the following:
> 
> 
> #macro F_Plane ()
>   #local fn_p=function (x,y,z) { y };
>   fn_p
> //  function (x,y,z) { fn_p (x,y,z) }
> #end
> 
> #local F1= F_Plane();
> 
> #declare fn_crash = function(x,y,z) { F1(x,y,z) }
> 
> 
> and got a POV access violation (official Win32 POV (MegaPOV crashes 
> too)). Commented code is a workaround.

It should not crash of course but your code isn't valid syntax, it can't 
work.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 25 Oct. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Warp
Subject: Re: POV crash with functions
Date: 10 Nov 2003 15:40:07
Message: <3faff7a7@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> It should not crash of course but your code isn't valid syntax, it can't 
> work.

  I have to admit that I'm not sure why it's not valid syntax... (Perhaps
you should have specified why? :) )

-- 
#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: caffeinebill
Subject: Re: POV crash with functions
Date: 10 Nov 2003 16:10:00
Message: <web.3faffdc7cd1be767d6c93cf30@news.povray.org>
JC (Exether) wrote:
>I tried to post this message three times in P.bugreports and it didn't
>work, sorry if I'm multiposting.
>
>So I wrote the following:
>
>
>#macro F_Plane ()
>   #local fn_p=function (x,y,z) { y };
>   fn_p
>//  function (x,y,z) { fn_p (x,y,z) }
>#end
>
>#local F1= F_Plane();
>
>#declare fn_crash = function(x,y,z) { F1(x,y,z) }
>
>
>and got a POV access violation (official Win32 POV (MegaPOV crashes
>too)). Commented code is a workaround.
>
>I hope that helps,
>
>JC
>

FYI

I tried the code as provided on Windows XP Professional, and received the
same error.


Post a reply to this message

From: Florian Brucker
Subject: Re: POV crash with functions
Date: 10 Nov 2003 16:32:19
Message: <3fb003e3@news.povray.org>
I can confirm the access violation using the above code with both 
official WinPOV 3.5 and MegaPOV 1.0 on WindowsME.

HTH,
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]


Post a reply to this message

From: Christoph Hormann
Subject: Re: POV crash with functions
Date: 10 Nov 2003 16:52:02
Message: <ehd581-m2l.ln1@triton.imagico.de>
Warp wrote:
>>It should not crash of course but your code isn't valid syntax, it can't 
>>work.
> 
>   I have to admit that I'm not sure why it's not valid syntax... (Perhaps
> you should have specified why? :) )

Are you serious?

#local fn_p=function (x,y,z) { y };

#local F1= fn_p;

#declare fn_crash = function(x,y,z) { F1(x,y,z) }


Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 25 Oct. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Warp
Subject: Re: POV crash with functions
Date: 10 Nov 2003 17:00:00
Message: <3fb00a5f@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> >   I have to admit that I'm not sure why it's not valid syntax... (Perhaps
> > you should have specified why? :) )

> Are you serious?

> #local fn_p=function (x,y,z) { y };

> #local F1= fn_p;

> #declare fn_crash = function(x,y,z) { F1(x,y,z) }

  Sorry, but I still don't see it. Perhaps I'm unusually dumb today.

  The only thing which I can think of is that you can't create an
identifier and directly assign a function to it (ie. #local F1 = fn_p;),
but if that's so, it's illogical and works differently from any other
identifier type.

  (Compare it to this: You have a #local A = sphere { 0,1 }; and
then you can do #local B = A; and you don't have to do it like
#local B = object { A };)

-- 
#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: Christoph Hormann
Subject: Re: POV crash with functions
Date: 10 Nov 2003 17:52:02
Message: <d5h581-cts.ln1@triton.imagico.de>
Warp wrote:
> 
>   Sorry, but I still don't see it. Perhaps I'm unusually dumb today.
> 
>   The only thing which I can think of is that you can't create an
> identifier and directly assign a function to it (ie. #local F1 = fn_p;),
> but if that's so, it's illogical and works differently from any other
> identifier type.
> 
>   (Compare it to this: You have a #local A = sphere { 0,1 }; and
> then you can do #local B = A; and you don't have to do it like
> #local B = object { A };)

This is to make it easy to distinguish between function calls and 
function declarations:

#local X=function (Y) { Y }

#local Y=0;

#local Val1=X(0);
#local Val2=X(Y);

#undef Y

#local Fn1=function (Y) { X(Y) }


I assume it would be possible to allow the '#local B = A' form for 
functions as well (although it might be difficult to implement) but 
possibilities for obfuscation are already sufficient IMO.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 25 Oct. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: POV crash with functions
Date: 10 Nov 2003 19:15:26
Message: <3fb02a1e@news.povray.org>
In article <3faff7a7@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>> It should not crash of course but your code isn't valid syntax, it can't
>> work.
>
>   I have to admit that I'm not sure why it's not valid syntax... (Perhaps
> you should have specified why? :) )

A local function is returned by value.  However, you cannot return a
function by value, you can only return a function result by value.  So after
the parser notices that this is a function assignment, it attempts to assign
it, but does of course fail because by the time it can notice, the macro has
already been left and the function no longer exists.  The reason is that
functions are not copied like other identifiers, but referenced (even if it
would be copied, the problem would remain to decide whether to copy or
evaluate).  However, the parser cannot decide what to do prior to leaving
the macro either.  Hence, this syntax cannot legal.

That said, I have no good idea how to tell the parser to detect such a case
yet (without some brain-dead ugly hack, of course).  Most likely this
problem will persist until POV-Ray 4.0.

    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: Thorsten Froehlich
Subject: Re: POV crash with functions
Date: 10 Nov 2003 19:21:13
Message: <3fb02b79$1@news.povray.org>
In article <3fafe73e@news.povray.org> , "JC (Exether)" <no### [at] spamfr> wrote:

> #macro F_Plane ()
>    #local fn_p=function (x,y,z) { y };
>    fn_p
> //  function (x,y,z) { fn_p (x,y,z) }
> #end

This isn't legal syntax and POV-Ray cannot currently detect this properly.

To do what you want, use #declare instead of #local like this:

#macro F_Plane ()
   #undef fn_p
   #declare fn_p=function (x,y,z) { y };
   fn_p
#end

    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

Goto Latest 10 Messages Next 5 Messages >>>

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