POV-Ray : Newsgroups : povray.beta-test : Function parameter bug Server Time
30 Jul 2024 16:27:29 EDT (-0400)
  Function parameter bug (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Rune
Subject: Function parameter bug
Date: 26 Oct 2001 17:17:45
Message: <3bd9d2f9@news.povray.org>
I'm not that much into how functions work and should work, but this surely
must be a bug?

The following code:

#declare V = 0.1;
#declare Myfunction = function (V) {V*2}
sphere {x, V}

Gives the error:

"#declare V = 0.1;

#declare Myfunction = function (V <----ERROR

Parse Error: Expected 'parameter identifier', float function 'float
identifier' found instead


Returned from renderer with error status"

I'm using POV-Ray 3.5 beta 6
on a P150, 16MB RAM
Windows 95  4.00.450 B  IE 5 5.00.2919.6307

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


Post a reply to this message

From: JRG
Subject: Re: Function parameter bug
Date: 26 Oct 2001 19:40:30
Message: <3bd9f46e@news.povray.org>
V does not represent your function, it's just a parameter. As it is now you
are telling povray to do:
#declare Myfunction (0.1) (0.1*2)
sphere {x, 0.1)
which isn't correct.

try something like this:

#declare Myfunction = function (V) {V*2}
sphere {x, Myfunction (0.1)}

--
Jonathan.


Post a reply to this message

From: Rune
Subject: Re: Function parameter bug
Date: 26 Oct 2001 20:18:22
Message: <3bd9fd4e@news.povray.org>
"JRG" wrote:
> V does not represent your function, it's just a
> parameter. As it is now you are telling povray to do:
> #declare Myfunction (0.1) (0.1*2)

But shouldn't the parameters use a different name-space than things declared
outside of the functions, just like it works with macros?

This:

#declare V = 0.1;
#include "math.inc"

gives an error because a function in math.inc uses V as a parameter! We
can't have that, now can we?

> try something like this:
>
> #declare Myfunction = function (V) {V*2}
> sphere {x, Myfunction (0.1)}

No because that's not what I want. I want the function to leave alone my
declared floats and stop bothering them.

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


Post a reply to this message

From: Christoph Hormann
Subject: Re: Function parameter bug
Date: 27 Oct 2001 02:54:33
Message: <3BDA5A29.18F49D99@gmx.de>
Rune wrote:
> 
> But shouldn't the parameters use a different name-space than things declared
> outside of the functions, just like it works with macros?
> 

Since it's leagal to use declared variables in functions, this would lead
to at least a lot of confusion.

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: JRG
Subject: Re: Function parameter bug
Date: 27 Oct 2001 04:48:55
Message: <3bda74f7@news.povray.org>
Ah aaah.... now I understand...
You want to give your float identifiers any name you want without bothering
that that name is already used somewhere (for example in math.inc) as a
function parameter. But why bother? Just use another identifier. Of course I
usually expect an uppercased identifier (such as R) to work in any
situation, but this could be just a minor problem in math.inc design.

--
Jonathan.

"Rune" <run### [at] mobilixnetdk> ha scritto nel messaggio
news:3bd9fd4e@news.povray.org...
> "JRG" wrote:
> > V does not represent your function, it's just a
> > parameter. As it is now you are telling povray to do:
> > #declare Myfunction (0.1) (0.1*2)
>
> But shouldn't the parameters use a different name-space than things
declared
> outside of the functions, just like it works with macros?
>
> This:
>
> #declare V = 0.1;
> #include "math.inc"
>
> gives an error because a function in math.inc uses V as a parameter! We
> can't have that, now can we?
>
> > try something like this:
> >
> > #declare Myfunction = function (V) {V*2}
> > sphere {x, Myfunction (0.1)}
>
> No because that's not what I want. I want the function to leave alone my
> declared floats and stop bothering them.
>
> Rune
> --
> 3D images and anims, include files, tutorials and more:
> Rune's World:    http://rsj.mobilixnet.dk (updated June 26)
> POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
> POV-Ray Webring: http://webring.povray.co.uk
>
>


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Function parameter bug
Date: 27 Oct 2001 05:48:55
Message: <3bda8307@news.povray.org>
In article <3bd9fd4e@news.povray.org> , "Rune" <run### [at] mobilixnetdk>
wrote:

> But shouldn't the parameters use a different name-space than things declared
> outside of the functions, just like it works with macros?

No, because one is the scene level and the other the parser level.  The
parser values are inserted first by substituting every variable you
declared.  The resulting scene file (which is invisible to you) is the
passed on the the actual parser which only sees the 0.1 as it should because
the "V" has been substituted by "0.1" as you requested.

You mistake is part of the functions are no macros misunderstanding!


    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: Rune
Subject: Re: Function parameter bug
Date: 27 Oct 2001 05:51:37
Message: <3bda83a9$1@news.povray.org>
"Christoph Hormann" wrote:
> Since it's leagal to use declared variables in functions,

When you *call* functions, not when you initiate them! At least it shouldn't
be since it makes no sense at all.

Take a macro:

#declare V = 0.1:
#macro MyMacro(V) V*2 #end
sphere {x, 0.1}

Here's there's no problem since the parameter in the macro doesn't conflict
with already declared variables. You can still call the macro with the
declared variable and *then* it will be used:

#declare B = MyMacro(V);

But with functions a conflict happens at the time of declaring the function
and that's all wrong.

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


Post a reply to this message

From: Rune
Subject: Re: Function parameter bug
Date: 27 Oct 2001 05:51:39
Message: <3bda83ab$1@news.povray.org>
"JRG" wrote:
> But why bother? Just use another identifier.

To use long cryptic parameter names and/or variable names just to avoid a
name conflicts is not an acceptable solution. You can never know if some
include file uses the same name you're using for your variables.

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


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Function parameter bug
Date: 27 Oct 2001 06:06:07
Message: <3bda870f@news.povray.org>
In article <3bda83a9$1@news.povray.org> , "Rune" 
<run### [at] mobilixnetdk> wrote:

> When you *call* functions, not when you initiate them! At least it shouldn't
> be since it makes no sense at all.
>
> Take a macro:
>
> #declare V = 0.1:
> #macro MyMacro(V) V*2 #end
> sphere {x, 0.1}
>
> Here's there's no problem since the parameter in the macro doesn't conflict
> with already declared variables. You can still call the macro with the
> declared variable and *then* it will be used:
>
> #declare B = MyMacro(V);
>
> But with functions a conflict happens at the time of declaring the function
> and that's all wrong.

Repeat after we:

Functions are not macros.  Functions are not macros.  Functions are not
macros.  Functions are not macros.   Functions are not macros. ...

    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: Rune
Subject: Re: Function parameter bug
Date: 27 Oct 2001 06:09:18
Message: <3bda87ce@news.povray.org>
"Thorsten Froehlich" wrote:
> The parser values are inserted first by substituting
> every variable you declared.

But it doesn't make sense to have parameters that are constant! And indeed
an error is generated as I reported! The *only* result of the way it woks
now is apparently that parameter names cannot use the same name as declared
variables and that's *very* inconvenient, as it's very common to use
one-letter names for both variables and for function parameters.

> You mistake is part of the functions are no macros misunderstanding!

But what's the logic behind how it works? It seems to be a big limitation
that have no positive effects at all...

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


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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