PCGen News and Notes is a Public Group with 7501 members.
 PCGen News and Notes

 Public Group,
 7501 members
Re: [DOCS] JEP update
Expand Messages
  In pcgen@yahoogroups.com, Eddy Anthony <eddyba@m...> wrote:
> On 8/3/04 3:17 PM, "Eric Beaudoin" <beaudoer@v...> wrote:
less than 1
>
> >> There is now a Boolean IF function
> >>
> >> if(CL,4,0)
> >>
> >> Boolean If [if(x,y,z)]. Asks if x is less than 1 then returns y, else
> >> returns z. In this example the operator asks if Class Level is
> >> then returns 4 or else returns 0.
anything
> >
> > Eddy, can you verify this. Normally with Booleans, 0 is false and
> > else is true. So 1, which is lower then 1 is true.
put it to
> >
> > Unless your example was supposed to be if(x<1,y,z).
>
> At this point I was translating what I found on the tracker, I'll
> the test in some LST this evening.
From what I can read from the code it works like this:
>
> The tracker says anything greater than 0 is interpreted as true so that
> would lead me to believe that 1 would return false, we'll see what my
> testing says.
> 
> ~ Eddy
> ~ PCGen BoD, Docs SB, LST Chimp, TM Lemur
x is either a boolean expression or a number.
Boolean => if x then y else z
Number => if (x > 0) then y else z
Ratheof Blithwyn
Data Lemur  You were right Eric, I got it backwards yesterday
if(CL,4,0)
Boolean If [if(x,y,z)]. Asks if x is greater than 0 then returns y, else
returns z.
In this example the operator asks if Class Level is greater than 0 then
returns 4 or else returns 0.

~ Eddy
~ PCGen BoD, Docs SB, LST Chimp, TM Lemur  At 13:15 2004.08.04, Eddy Anthony wrote:
>You were right Eric, I got it backwards yesterday
Heu... this is what I thought was in error to begin with.
>
>if(CL,4,0)
>
>Boolean If [if(x,y,z)]. Asks if x is greater than 0 then returns y, else
>returns z.
> In this example the operator asks if Class Level is greater than 0 then
>returns 4 or else returns 0.
Let me be clearer: if(1,true_value,false_value). In this case, the if function should return true_value. If it returns false_value, it is a bug.
The main thing is to define TRUE properly (the Truth is out there but it's hard to define :). The most common definition of TRUE is "everything that is not FALSE".
I know, this sounds like a smart ass answer but it isn't. FALSE is way easier to define than TRUE.
FALSE = 0, 0.0, the empty string ("") or undefined variables.
I think you tested the if() function. If it does not behave properly, could you please put in a tracker to have it fixed. Let's not create our own personal definition of TRUE and FALSE (it goes against the Principle of Least Surprise).
Best

Éric "Space Monkey" Beaudoin
Founding Member of the HiddenintheTrench Club
Release Monkey in training>> In space, no one can hear you sleep.
<mailto:beaudoer@...>
>> Camels to can climb trees (and sometime eat them).
 Ah, I follow you, though I can see uses for both functionalities I can also
see how to work around it if it were fixed to how you state it should work.
I tend to agree with your point of view about it though. I've opened a bug
tracker for this:
[ 1003437 ] if(x,y,z) should return false only on 0
On 8/4/04 1:48 PM, "Eric Beaudoin" <beaudoer@...> wrote:
> At 13:15 2004.08.04, Eddy Anthony wrote:
>> You were right Eric, I got it backwards yesterday
>>
>> if(CL,4,0)
>>
>> Boolean If [if(x,y,z)]. Asks if x is greater than 0 then returns y, else
>> returns z.
>> In this example the operator asks if Class Level is greater than 0 then
>> returns 4 or else returns 0.
>
> Heu... this is what I thought was in error to begin with.
>
> Let me be clearer: if(1,true_value,false_value). In this case, the if
> function should return true_value. If it returns false_value, it is a bug.
>
> The main thing is to define TRUE properly (the Truth is out there but it's
> hard to define :). The most common definition of TRUE is "everything that is
> not FALSE".
>
> I know, this sounds like a smart ass answer but it isn't. FALSE is way easier
> to define than TRUE.
>
> FALSE = 0, 0.0, the empty string ("") or undefined variables.
>
> I think you tested the if() function. If it does not behave properly, could
> you please put in a tracker to have it fixed. Let's not create our own
> personal definition of TRUE and FALSE (it goes against the Principle of Least
> Surprise).
>
> Best

~ Eddy
~ PCGen BoD, Docs SB, LST Chimp, TM Lemur  In the docs, be sure to include an example like
if((CL<4),1,2)
i.e. with an actual boolean expression which IMO would be more natural
since it is what one is after here. We are talking about an if
statement after all. For the sake of readability avoid assumptions of
underlying representation please.
Ratheof Blithwyn
Data Lemur
 In pcgen@yahoogroups.com, Eddy Anthony <eddyba@m...> wrote:
> Ah, I follow you, though I can see uses for both functionalities I
can also
> see how to work around it if it were fixed to how you state it
should work.
> I tend to agree with your point of view about it though. I've opened
a bug
> tracker for this:
>
> [ 1003437 ] if(x,y,z) should return false only on 0
>
> On 8/4/04 1:48 PM, "Eric Beaudoin" <beaudoer@v...> wrote:
>
> > At 13:15 2004.08.04, Eddy Anthony wrote:
> >> You were right Eric, I got it backwards yesterday
> >>
> >> if(CL,4,0)
> >>
> >> Boolean If [if(x,y,z)]. Asks if x is greater than 0 then returns
y, else
> >> returns z.
> >> In this example the operator asks if Class Level is greater than
0 then
> >> returns 4 or else returns 0.
> >
> > Heu... this is what I thought was in error to begin with.
> >
> > Let me be clearer: if(1,true_value,false_value). In this case, the if
> > function should return true_value. If it returns false_value, it
is a bug.
> >
> > The main thing is to define TRUE properly (the Truth is out there
but it's
> > hard to define :). The most common definition of TRUE is
"everything that is
> > not FALSE".
> >
> > I know, this sounds like a smart ass answer but it isn't. FALSE is
way easier
> > to define than TRUE.
> >
> > FALSE = 0, 0.0, the empty string ("") or undefined variables.
> >
> > I think you tested the if() function. If it does not behave
properly, could
> > you please put in a tracker to have it fixed. Let's not create our own
> > personal definition of TRUE and FALSE (it goes against the
Principle of Least
> > Surprise).
> >
> > Best
>
> 
> ~ Eddy
> ~ PCGen BoD, Docs SB, LST Chimp, TM Lemur  At 14:10 2004.08.04, blithwyn wrote:
>In the docs, be sure to include an example like
I agree with you. I would remove the extra parentasis though since that don't really improve readability: if(CL>0,x,y) would be similar to the example Eddy was giving.
>if((CL<4),1,2)
>i.e. with an actual boolean expression which IMO would be more natural
>since it is what one is after here. We are talking about an if
>statement after all. For the sake of readability avoid assumptions of
>underlying representation please.
>
>Ratheof Blithwyn
>Data Lemur

Éric "Space Monkey" Beaudoin
Founding Member of the HiddenintheTrench Club
Release Monkey in training>> In space, no one can hear you sleep.
<mailto:beaudoer@...>
>> Camels to can climb trees (and sometime eat them).
> In the docs, be sure to include an example like
Please include examples that exemplify *all* of the functionality.
> if((CL<4),1,2)
> i.e. with an actual boolean expression which IMO would be more natural
> since it is what one is after here.
"if(CL,1,2)" is a valid example, and should be included with a full
explanation of the results for zero and nonzero values of CL.
"if(CL=0,2,1)" is also valid, even though functionaly identical to the
first, and should also be explained.
> We are talking about an if statement after all. For the sake of
But don't leave them out, as an understanding of them can lead to
> readability avoid assumptions of underlying representation please.
simplifications in expressions, which *may* lead to increases in the
efficiency of the evaluation.
>
> Ratheof Blithwyn
> Data Lemur
>
>
>  In pcgen@yahoogroups.com, Eddy Anthony <eddyba@m...> wrote:
> > Ah, I follow you, though I can see uses for both functionalities I
> can also
> > see how to work around it if it were fixed to how you state it
> should work.
> > I tend to agree with your point of view about it though. I've opened
> a bug
> > tracker for this:
> >
> > [ 1003437 ] if(x,y,z) should return false only on 0
> >
> > On 8/4/04 1:48 PM, "Eric Beaudoin" <beaudoer@v...> wrote:
> >
> > > At 13:15 2004.08.04, Eddy Anthony wrote:
> > >> You were right Eric, I got it backwards yesterday
> > >>
> > >> if(CL,4,0)
> > >>
> > >> Boolean If [if(x,y,z)]. Asks if x is greater than 0 then returns
> y, else
> > >> returns z.
> > >> In this example the operator asks if Class Level is greater than
> 0 then
> > >> returns 4 or else returns 0.
> > >
> > > Heu... this is what I thought was in error to begin with.
> > >
> > > Let me be clearer: if(1,true_value,false_value). In this case, the if
> > > function should return true_value. If it returns false_value, it
> is a bug.
> > >
> > > The main thing is to define TRUE properly (the Truth is out there
> but it's
> > > hard to define :). The most common definition of TRUE is
> "everything that is
> > > not FALSE".
> > >
> > > I know, this sounds like a smart ass answer but it isn't. FALSE is
> way easier
> > > to define than TRUE.
> > >
> > > FALSE = 0, 0.0, the empty string ("") or undefined variables.
> > >
> > > I think you tested the if() function. If it does not behave
> properly, could
> > > you please put in a tracker to have it fixed. Let's not create our own
> > > personal definition of TRUE and FALSE (it goes against the
> Principle of Least
> > > Surprise).
> > >
> > > Best
> >
> > 
> > ~ Eddy
> > ~ PCGen BoD, Docs SB, LST Chimp, TM Lemur
>
>
>
>
> PCGen's release site: http://pcgen.sourceforge.net
> PCGen's alpha build: http://rpg.plambert.net/pcgen
> PCGen's FAQ:
> http://rpg.plambert.net/pcgen/current/_docs/
> Yahoo! Groups Links
>
>
>
>
> Thanks for the feed back everybody, very helpful stuff. I've expanded the
entry to try and be more clear. What do you think?

~ Eddy
~ PCGen BoD, Docs SB, LST Chimp, TM Lemur

Boolean If operator
if(x,y,z)
The boolean if operator will return one of two results after evaluating a
boolean. The variable x is a boolean result, 0 is false and 1 is true. The
variable y is the result returned if x is true, z is the result returned if
x is false. Put another way, if x is true (1) then the result is y, is not
then the result is z. Because x should either be 0 or 1 it makes the sense
to use a boolean expression, though this is not required.
At this time 0 or less is evaluated as false and 1 or greater is evaluated
as true, this may be changed in the future so that only 0 will return as
false and all other numbers return as true.
Examples:
if(CL<4,10,0)
Asks if Class Level is less than 4 then returns 10 or else returns 0.
if(CL>=4,10,0)
Asks if Class Level is greater than or equal to 4 then returns 10 or else
returns 0.
if((CL>5)(TL>5),2,4)
Asks if Class Level or Total Level is greater than 5 then returns 2 or else
returns 4.
if(STR,5,0)
Asks if Strength modifier is greater than 0 then returns 5 or else returns
0. Note that while this is valid it makes more sense to express it like
this: if(STR>0,5,0) > if(STR,5,0)
One minor nit, if I've understood the previous discussion properly, what
>
> Asks if Strength modifier is greater than 0 then returns 5 or
> else returns
> 0.
this example actually does is check if STR mod is nonzero. The main
eaxample and the alternate will *not* yield the same results if the STR mod
is less than zero.
> Note that while this is valid it makes more sense to
IOW, with a strength score of 8, and a modifier of 1, "if(STR,5,0)" will
> express it like this:
> if(STR>0,5,0)
return 5, whereas "if(STR>0,5,0)" will return 0.
Brass Quoting Brass Tilde <brasstilde@...>:
> One minor nit, if I've understood the previous discussion properly, what
The code was originally written so that if arg1 > 0, arg2 was returned,
> this example actually does is check if STR mod is nonzero. The main
> eaxample and the alternate will *not* yield the same results if the STR mod
> is less than zero.
else arg3 was returned. I've just committed a change to bring the code up to
speed with this discussion: e.g., if arg1 != 0, arg2 is returned, else arg3 is
returned. So if(STR,5,0) returns 5 unless STR==0. I can easily back this out
if people disagree.
Ross  On Wed, Aug 04, 2004 at 06:02:35PM 0400, Eddy Anthony wrote:
> 
I don't recall ever seeing '0 or less' evaluated false except here.
> Boolean If operator
>
> if(x,y,z)
>
> The boolean if operator will return one of two results after
> evaluating a boolean. The variable x is a boolean result, 0 is false
> and 1 is true. The variable y is the result returned if x is true, z
> is the result returned if x is false. Put another way, if x is true
> (1) then the result is y, is not then the result is z. Because x
> should either be 0 or 1 it makes the sense to use a boolean
> expression, though this is not required.
>
> At this time 0 or less is evaluated as false and 1 or greater is
> evaluated as true, this may be changed in the future so that only 0
> will return as false and all other numbers return as true.
I've only seen a few languages that do boolean math on numerics (C/C++,
Perl, and Visual Basic); in all cases 0 is interpreted as false and
non0 is interpreted as true (TRUE is defined as 1 in VB, FWIW).
Treating '0 or less' as false runs against the common behavior in common
programming languages. While I like boolean evaluation of numerics, I
would either support it in the common form, or drop it altogether and
require explicit boolean evaluation (as Java does).
As Brad says, princple of least surprise. The example you give below
"if(STR,5,0)" reads to me like 'if STR is nonzero', not 'if STR > 0'.
> Examples:
Contrived example, I know, but CL>5 cannot be true unless TL>5 is true;
>
> if(CL<4,10,0)
>
> Asks if Class Level is less than 4 then returns 10 or else returns 0.
>
> if(CL>=4,10,0)
>
> Asks if Class Level is greater than or equal to 4 then returns 10 or else
> returns 0.
>
> if((CL>5)(TL>5),2,4)
>
> Asks if Class Level or Total Level is greater than 5 then returns 2 or else
> returns 4.
TL.5 is a sufficient test here.
> if(STR,5,0)
Quite. Especially given how many people would interpret that as looking
>
> Asks if Strength modifier is greater than 0 then returns 5 or else
> returns 0. Note that while this is valid it makes more sense to
> express it like this: if(STR>0,5,0)
for STR to be 0 or non0, rather that >0 or <= 0.
Keith

Keith Davies I gave my 2yo daughter a strawberry
keith.davies@... Naomi: "Strawberry!"
me: "What do you say?"
Naomi: "*MY* strawberry!"  On Wed, Aug 04, 2004 at 03:24:17PM 0700, Ross M. Lodge wrote:
> Quoting Brass Tilde <brasstilde@...>:
No, don't. This makes sense now.
>
> > One minor nit, if I've understood the previous discussion properly, what
> > this example actually does is check if STR mod is nonzero. The main
> > eaxample and the alternate will *not* yield the same results if the STR mod
> > is less than zero.
>
>
> The code was originally written so that if arg1 > 0, arg2 was
> returned, else arg3 was returned. I've just committed a change to
> bring the code up to speed with this discussion: e.g., if arg1 != 0,
> arg2 is returned, else arg3 is returned. So if(STR,5,0) returns 5
> unless STR==0. I can easily back this out if people disagree.
It looks like your examples got slightly out of sync with the code, is
all.
Keith

Keith Davies I gave my 2yo daughter a strawberry
keith.davies@... Naomi: "Strawberry!"
me: "What do you say?"
Naomi: "*MY* strawberry!" > The code was originally written so that if arg1 > 0,
That makes sense to me, as long as actual comparative expressions, such as a
> arg2 was returned,
> else arg3 was returned. I've just committed a change to
> bring the code up to
> speed with this discussion: e.g., if arg1 != 0, arg2 is
> returned, else arg3 is
> returned. So if(STR,5,0) returns 5 unless STR==0. I can
> easily back this out
> if people disagree.
> b, evaluate to zero if false, and nonzero if true.
Brad
 On Wed, Aug 04, 2004 at 06:02:35PM 0400, Eddy Anthony wrote:
> Thanks for the feed back everybody, very helpful stuff. I've expanded the
I think it could be clearer in places, you seem to be confused about
> entry to try and be more clear. What do you think?
> 
> ~ Eddy
> ~ PCGen BoD, Docs SB, LST Chimp, TM Lemur
>
> 
> Boolean If operator
>
> if(x,y,z)
>
> The boolean if operator will return one of two results after evaluating a
> boolean. The variable x is a boolean result, 0 is false and 1 is true. The
> variable y is the result returned if x is true, z is the result returned if
> x is false. Put another way, if x is true (1) then the result is y, is not
> then the result is z. Because x should either be 0 or 1 it makes the sense
> to use a boolean expression, though this is not required.
>
> At this time 0 or less is evaluated as false and 1 or greater is evaluated
> as true, this may be changed in the future so that only 0 will return as
> false and all other numbers return as true.
>
> Examples:
>
> if(CL<4,10,0)
>
> Asks if Class Level is less than 4 then returns 10 or else returns 0.
>
> if(CL>=4,10,0)
>
> Asks if Class Level is greater than or equal to 4 then returns 10 or else
> returns 0.
>
> if((CL>5)(TL>5),2,4)
>
> Asks if Class Level or Total Level is greater than 5 then returns 2 or else
> returns 4.
>
> if(STR,5,0)
>
> Asks if Strength modifier is greater than 0 then returns 5 or else returns
> 0. Note that while this is valid it makes more sense to express it like
> this: if(STR>0,5,0)
exactly what represents true and what represents false. First you say
only 0 and 1 are valid, then you tell us that any number less than
1 is false, number greater than or equal to 1 are true. how about.

Boolean If operator
if(x,y,z)
The boolean if operator will return one of two results after evaluating a
boolean expression. x represents a boolean expression, if x evaluates to
true then y is returned, otherwise, z is returned.
At this time numbers less than or equal to 0 are evaluated as false.
Numbers greater than or equal to 1 are evaluated as true, this may be
changed in the future so that only 0 will be false  all other numbers
will be true.
I have no idea why you included this next bit, it makes no sense to
me. Every expression (even a single variable) may be evaluated in a
boolean context. In a boolean context, it will either be true or
false (for some definition of true and false  see above).
> Because x should either be 0 or 1 it makes the sense
Examples:
> to use a boolean expression, though this is not required.
if(CL<4,10,0)
Returns 10 if Class Level is less than 4 otherwise it returns 0.
if(CL>=4,10,0)
Returns 10 if Class Level is greater than or equal to 4 otherwise it
returns 0.
if((CL>5)(TL>5),2,4)
Returns 2 if either Class Level is greater than 5 or Total Level is
greater than 5 otherwise it returns 4.
if(STR,5,0)
Returns 5 if Strength modifier is greater than 0 otherwise it returns 0.
Note that while this is valid it makes more sense to express it like
this:
if(STR>0,5,0)
this will continue to work if the definitions of true and false are
changed to become more standard.
&ru

Aries: (March 21  April 19)
You know that one day you'll have to tell your family you're not
really a chicken, but for now they really need the eggs.  Quoting Andrew Wilson <pcgen@...>:
> > At this time 0 or less is evaluated as false and 1 or greater is evaluated
This _has_ been changed...in the current CVS tree.
> > as true, this may be changed in the future so that only 0 will return as
> > false and all other numbers return as true.
Ross  I think we have consensus!
Thanks Ross, I think that change makes sense.

~ Eddy
~ PCGen BoD, Docs SB, LST Chimp, TM Lemur

Boolean If operator (revisited)
if(x,y,z)
The boolean if operator will return one of two results after evaluating a
boolean. The variable x is a boolean result, 0 is false and anything not 0
is true. The variable y is the result returned if x is true, z is the result
returned if x is false. Put another way, if x is true (not 0) then the
result is y, is x is false (0) then the result is z.
Examples:
if(CL<10,1,2)
Asks if Class Level is less than 10 then returns 1 or else returns 2.
if(CL>=4,10,0)
Asks if Class Level is greater than or equal to 4 then returns 10 or else
returns 0.
if((CL>5)(TL>5),2,4)
Asks if Class Level or Total Level is greater than 5 then returns 2 or else
returns 4.
if(STR,5,0)
Asks if Strength modifier is greater than or less than 0 then returns 5 or
else returns 0.  <quote who="Brass Tilde">
> Please include examples that exemplify *all* of the functionality.
The functionaity is not the same ;O)
> "if(CL,1,2)" is a valid example, and should be included with a full
> explanation of the results for zero and nonzero values of CL.
>
> "if(CL=0,2,1)" is also valid, even though functionaly identical to the
> first, and should also be explained.
The first example will evaluate the value of "CL" So it will return a true
(non zero value) when CL is non zero.
the second example will evaluate the value of "CL=0" So it will return '1'
when CL equals 0 and 0 all other times.
The 2 examples are actualy inverses of each other.

regards,
Frugal
OS Chimp > <quote who="Brass Tilde">
Yes it is. Note the change in position of the truepart and falsepart
> > Please include examples that exemplify *all* of the functionality.
> > "if(CL,1,2)" is a valid example, and should be included with a full
> > explanation of the results for zero and nonzero values of CL.
> >
> > "if(CL=0,2,1)" is also valid, even though functionaly identical to the
> > first, and should also be explained.
>
> From: "Frugal"
> The functionaity is not the same ;O)
parameters between the first and second example.
> The first example will evaluate the value of "CL" So it will return a true
"if(CL,1,2)" will return 1 if CL is nonzero, and 2 if CL is zero.
> (non zero value) when CL is non zero.
> the second example will evaluate the value of "CL=0" So it will return '1'
"if(CL=0,2,1)" will also return 1 if CL is nonzero, and 2 if CL is zero.
> when CL equals 0 and 0 all other times.
> The 2 examples are actualy inverses of each other.
The expressions being evaluated are inverse, however, the way they are used
causes each example to return the same value, thus they are functionaly
identical. On Thursday 05 August 2004 12:30, Brass Tilde wrote:
> > <quote who="Brass Tilde">
Doh!!!
> >
> > > Please include examples that exemplify *all* of the functionality.
> > > "if(CL,1,2)" is a valid example, and should be included with a full
> > > explanation of the results for zero and nonzero values of CL.
> > >
> > > "if(CL=0,2,1)" is also valid, even though functionaly identical to the
> > > first, and should also be explained.
> >
> > From: "Frugal"
> > The functionaity is not the same ;O)
>
> Yes it is. Note the change in position of the truepart and falsepart
> parameters between the first and second example.

regards,
Frugal
OS Chimp
Your message has been successfully submitted and would be delivered to recipients shortly.