POV-Ray : Newsgroups : povray.bugreports : Cannot predeclare spline for function Server Time
6 Nov 2025 07:09:24 EST (-0500)
  Cannot predeclare spline for function (Message 1 to 8 of 8)  
From: Bald Eagle
Subject: Cannot predeclare spline for function
Date: 3 Nov 2025 18:50:00
Message: <web.69093eba846e68f41f9dae3025979125@news.povray.org>
The docs show:

#declare foo2 = function {
  spline {
    linear_spline
    0.0, <0,0,0>
    0.5, <1,0,0>
    1.0, <0,0,0>
    }
  }

#declare myvector2 = foo2(0.7);


I am testing code that has:

#declare SPL2_PX = spline{
        linear_spline
        #for(S_K, 0, S_NSites2D-1)
            S_K, A1D_V_P2D[S_K].x,
        #end
    }

#declare S_PX2 = function {SPL2_PX}

Parse Error: Expected 'operand', spline identifier found instead

Unless I'm doing something wrong.  Which is rather often the case.

- BE


Post a reply to this message

From: Leroy
Subject: Re: Cannot predeclare spline for function
Date: 3 Nov 2025 19:45:00
Message: <web.69094b6e672aec277de98b7f712fc00@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> The docs show:
>
> #declare foo2 = function {
>   spline {
>     linear_spline
>     0.0, <0,0,0>
>     0.5, <1,0,0>
>     1.0, <0,0,0>
>     }
>   }
>
> #declare myvector2 = foo2(0.7);
>
>
> I am testing code that has:
>
> #declare SPL2_PX = spline{
>         linear_spline
>         #for(S_K, 0, S_NSites2D-1)
>             S_K, A1D_V_P2D[S_K].x,
>         #end
>     }
>
> #declare S_PX2 = function {SPL2_PX}
>
> Parse Error: Expected 'operand', spline identifier found instead
>
> Unless I'm doing something wrong.  Which is rather often the case.
>
> - BE

I found it! The function can not use a predefined spline so if you want a
function to use a spline define the spline in the function

#declare S_PX2 = function {
        spline{
         linear_spline
         #for(S_K, 0, S_NSites2D-1)
             S_K, A1D_V_P2D[S_K].x,
         #end
     }}
Works for me!
Have Fun!


Post a reply to this message

From: Bald Eagle
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 06:20:00
Message: <web.6909e0e4672aec271f9dae3025979125@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

> #declare S_PX2 = function {
>         spline{
>          linear_spline
>          #for(S_K, 0, S_NSites2D-1)
>              S_K, A1D_V_P2D[S_K].x,
>          #end
>      }}

Yes and that is indeed what I did.

However it seems to be bad behaviour by the parser, and locks the spline into a
single-use object.

IIRC, I can use pre-declared splines in sphere_sweep without a problem.

The inability falls under the "contrary to user expectation", and that's why
it's in this section.

Thank you, of course, for providing the workaround.
I wonder how many other things we have like this lurking around in the source.

- BE


Post a reply to this message

From: jr
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 07:00:00
Message: <web.6909e9a7672aec27475fba6a6cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
>
> > #declare S_PX2 = function {
> >         spline{
> >          linear_spline
> >          #for(S_K, 0, S_NSites2D-1)
> >              S_K, A1D_V_P2D[S_K].x,
> >          #end
> >      }}
>
> Yes and that is indeed what I did.
>
> However it seems to be bad behaviour by the parser, and locks the spline into a
> single-use object.
>
> IIRC, I can use pre-declared splines in sphere_sweep without a problem.
>
> The inability falls under the "contrary to user expectation", and that's why
> it's in this section.
>
> Thank you, of course, for providing the workaround.
> I wonder how many other things we have like this lurking around in the source.

it actually does work, though you have to tell the function:

#declare S_PX2 = function {spline{SPL2_PX}};


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 08:05:00
Message: <web.6909f989672aec271d71f3c25979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> it actually does work, though you have to tell the function:
>
> #declare S_PX2 = function {spline{SPL2_PX}};

I quickly tried one or two constructs pointed in this direction, but clearly
didn't land on that one.

Good to know for future code edits.

As always,
Thanks!  :)

- bw


Post a reply to this message

From: Thorsten
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 11:27:56
Message: <690a298c$1@news.povray.org>
On 04.11.2025 12:17, Bald Eagle wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
> 
>> #declare S_PX2 = function {
>>          spline{
>>           linear_spline
>>           #for(S_K, 0, S_NSites2D-1)
>>               S_K, A1D_V_P2D[S_K].x,
>>           #end
>>       }}
> 
> Yes and that is indeed what I did.
> 
> However it seems to be bad behaviour by the parser, and locks the spline into a
> single-use object.
> 
> IIRC, I can use pre-declared splines in sphere_sweep without a problem.
> 
> The inability falls under the "contrary to user expectation", and that's why
> it's in this section.

Not behaves exactly as designed: The function parser cannot handle 
declared objects because you are falling into the POV-Ray declares are 
not macros trap. The parser first needs to know that you want a spline 
function, then it can make use of the spline object.

Thorsten


Post a reply to this message

From: Thorsten
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 11:30:05
Message: <690a2a0d$1@news.povray.org>
On 04.11.2025 12:55, jr wrote:
> it actually does work, though you have to tell the function:
> 
> #declare S_PX2 = function {spline{SPL2_PX}};

Exactly! And that is the logical way to do this, too. First tell the 
parser that you actually want a spline function, then you can use a 
spline. The regular syntax declares a plain function, not a spline function.

Thorsten


Post a reply to this message

From: jr
Subject: Re: Cannot predeclare spline for function
Date: 4 Nov 2025 12:00:00
Message: <web.690a30df672aec27475fba6a6cde94f1@news.povray.org>
hi,

Thorsten <tho### [at] trfde> wrote:
> On 04.11.2025 12:55, jr wrote:
> > it actually does work, though you have to tell the function:
> >
> > #declare S_PX2 = function {spline{SPL2_PX}};
>
> Exactly! And that is the logical way to do this, too. First tell the
> parser that you actually want a spline function, then you can use a
> spline. The regular syntax declares a plain function, not a spline function.

agree with the "consistent" point in the other post, the situation is exactly
like, say, with a 'pigment {}'.


regards, jr.


Post a reply to this message

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