POV-Ray : Newsgroups : povray.advanced-users : Passing function to macros? Server Time
1 Nov 2024 15:26:10 EDT (-0400)
  Passing function to macros? (Message 1 to 6 of 6)  
From: Rune
Subject: Passing function to macros?
Date: 5 Apr 2002 17:32:31
Message: <3cae25ff$1@news.povray.org>
I'm not sure - is it supposed in beta 15 to be possible to pass functions to
macros? How do I do that? ...when using more than just the x, y, and z
variables?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Mar 19)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From:
Subject: Re: Passing function to macros?
Date: 5 Apr 2002 17:39:28
Message: <4r9saugdvotfhnuj5m861fgqks0ei3reb8@4ax.com>
On Sat, 6 Apr 2002 00:33:10 +0200, "Rune" <run### [at] mobilixnetdk> wrote:
> I'm not sure - is it supposed in beta 15 to be possible to pass functions to
> macros? How do I do that? ...when using more than just the x, y, and z
> variables?

#local Sum=function( A , B , C , D , E , F ) { A + B + C + D + E + F };
#macro Run( F )
  #local Result = F( 1,2,3,4,5,6 );
  #warning str( Result , 0 , -1 )
#end
Run( function(A,B,C,D,E,F){ Sum(A,B,C,D,E,F) } )
  
ABX


Post a reply to this message

From: Rune
Subject: Re: Passing function to macros?
Date: 5 Apr 2002 18:26:20
Message: <3cae329c$1@news.povray.org>

> Run( function(A,B,C,D,E,F){ Sum(A,B,C,D,E,F) } )

Oh, right... thanks!

I really hate the way functions are passed to macros though. It's a whole
new level of clumsiness... :(

I wish it could be possible to do:

Run(Sum)

But that won't happen before POV-Ray 4.0, and that's just if we're lucky...
(This is not a critique to the POV-Team at all).

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Mar 19)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Hugo
Subject: Re: Passing function to macros?
Date: 6 Apr 2002 05:50:21
Message: <3caed2ed$1@news.povray.org>
> I wish it could be possible to do:
>
> Run(Sum)

I agree, this would be logical.
Strange that it doesn't work.

Regards,
Hugo


Post a reply to this message

From:
Subject: Re: Passing function to macros?
Date: 6 Apr 2002 06:48:17
Message: <pvntauok9unva6rbvloj6takn3j6flol1e@4ax.com>
On Sat, 6 Apr 2002 12:58:47 +0200, "Hugo" <hua### [at] post3teledk> wrote:
> I agree, this would be logical.
> Strange that it doesn't work.

Feel free to investigate difficulties of implementation after source release :-)

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Passing function to macros?
Date: 6 Apr 2002 14:51:23
Message: <3caf51bb@news.povray.org>
In article <3caed2ed$1@news.povray.org> , "Hugo" <hua### [at] post3teledk> wrote:

> Strange that it doesn't work.

In computer science terms (and as it has been explained several times before),
the current POV-Ray parser is a recursive decent parser which is a plain and
simple LL(1) parser.  In order to parse "Run(Sum)" one needs a more complex
LR(1) parser to handle the more complex grammar.  Essentially an LR(k) parser,
just like a human, is able to read to the end of a sentence and then able to
make sense out of it while the LL(k) parser is only able to look at the next
word and then has to guess what you are up to without having read to the end.

This said however, I have to admit that LR(1) is only relevant for some "odd"
features of #declares and not macro parameters.  In order to parse macro
parameters correctly it is sufficient to modify the current parser to be
"nearly an LL(2) parser".  To be more precise, by some tricky but small
internal changes it is possible to keep enough information and perform a two
token look-ahead for functions*, which is sufficient to determine if it is a
function call or not...


    Thorsten


* I have not checked yet if the same is possible for splines with easy
modifications as well.

____________________________________________________
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

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