POV-Ray : Newsgroups : povray.newusers : Expected 'operator', ? found instead Server Time
24 Nov 2024 10:35:40 EST (-0500)
  Expected 'operator', ? found instead (Message 1 to 5 of 5)  
From: Mathuin
Subject: Expected 'operator', ? found instead
Date: 5 Oct 2008 03:10:01
Message: <web.48e867521f7a504fd8a103ef0@news.povray.org>
I'm trying to use the conditional expression in a function and get the following
error message:

Parse Error: Expected 'operator', ? found instead

Here's my function:

#local ScoreStone = function(x) { (x=1) ? white_stone : black_stone }

What am I doing wrong?  I thought ? was an operator -- that's what the docs say.
 It happens on Windows with both 3.7 beta 28 and 3.6 as well as on Unix with
3.6.  Thanks!


Post a reply to this message

From: Mike Williams
Subject: Re: Expected 'operator', ? found instead
Date: 5 Oct 2008 03:37:46
Message: <se+0giAG7G6IFwPV@econym.demon.co.uk>
Wasn't it Mathuin who wrote:
>I'm trying to use the conditional expression in a function and get the 
>following
>error message:
>
>Parse Error: Expected 'operator', ? found instead
>
>Here's my function:
>
>#local ScoreStone = function(x) { (x=1) ? white_stone : black_stone }
>
>What am I doing wrong?  I thought ? was an operator -- that's what the 
>docs say.
> It happens on Windows with both 3.7 beta 28 and 3.6 as well as on Unix with
>3.6.  Thanks!


The syntax inside functions is different from that of the main SDL. It 
doesn't have "?" but it does have "select".

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Mathuin
Subject: Re: Expected 'operator', ? found instead
Date: 5 Oct 2008 04:40:00
Message: <web.48e87d0f38f591c7d8a103ef0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
\> The syntax inside functions is different from that of the main SDL. It
> doesn't have "?" but it does have "select".

I ended up making a macro instead of a function.

'white_stone' is 'stone(1, 1, 1)' and 'black_stone' is 'stone(0, 0, 0)' so I
have this which works:

#macro ScoreStone(i)
stone(i ? 1 : 0, i ? 1 : 0, i ? 1 : 0)
#end // macro ScoreStone(i)

It's kinda ugly, but it definitely works.

Thank you for the pointer to select() -- I will use that in the future.

>
> --
> Mike Williams
> Gentleman of Leisure


Post a reply to this message

From: Mathuin
Subject: Re: Expected 'operator', ? found instead
Date: 5 Oct 2008 06:40:00
Message: <web.48e8990438f591c7d8a103ef0@news.povray.org>
"Mathuin" <mat### [at] gmailcom> wrote:
> Mike Williams <nos### [at] econymdemoncouk> wrote:
> \> The syntax inside functions is different from that of the main SDL. It
> > doesn't have "?" but it does have "select".
>
> I ended up making a macro instead of a function.
>
> 'white_stone' is 'stone(1, 1, 1)' and 'black_stone' is 'stone(0, 0, 0)' so I
> have this which works:
>
> #macro ScoreStone(i)
> stone(i ? 1 : 0, i ? 1 : 0, i ? 1 : 0)
> #end // macro ScoreStone(i)

I have since changed this to:

#macro ScoreStone(i)
stone(i, i, i)
#end // macro ScoreStone(i)

as i is either 0 or 1.  Whee.  Thank you again. :-P :-)

>
> It's kinda ugly, but it definitely works.
>
> Thank you for the pointer to select() -- I will use that in the future.
>
> >
> > --
> > Mike Williams
> > Gentleman of Leisure


Post a reply to this message

From: Alain
Subject: Re: Expected 'operator', ? found instead
Date: 9 Oct 2008 13:10:56
Message: <48ee3b20@news.povray.org>
Mathuin nous illumina en ce 2008-10-05 06:37 -->
> "Mathuin" <mat### [at] gmailcom> wrote:
>> Mike Williams <nos### [at] econymdemoncouk> wrote:
>> \> The syntax inside functions is different from that of the main SDL. It
>>> doesn't have "?" but it does have "select".
>> I ended up making a macro instead of a function.
>>
>> 'white_stone' is 'stone(1, 1, 1)' and 'black_stone' is 'stone(0, 0, 0)' so I
>> have this which works:
>>
>> #macro ScoreStone(i)
>> stone(i ? 1 : 0, i ? 1 : 0, i ? 1 : 0)
>> #end // macro ScoreStone(i)
> 
> I have since changed this to:
> 
> #macro ScoreStone(i)
> stone(i, i, i)
> #end // macro ScoreStone(i)
> 
> as i is either 0 or 1.  Whee.  Thank you again. :-P :-)
> 
>> It's kinda ugly, but it definitely works.
>>
>> Thank you for the pointer to select() -- I will use that in the future.
>>
>>> --
>>> Mike Williams
>>> Gentleman of Leisure
> 
> 
> 
> 
Your final solution does have an advantage, beside simplicity: you are no longer 
limited to only white or black, you can now have any shade of gray.

-- 
Alain
-------------------------------------------------
"The fact that windows is one of the most popular ways to operate a computer 
means that evolution has made a general fuckup and our race is doomed." 
            -- Anon.


Post a reply to this message

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