1. RE: BUG in EUPHORIA PARSER
So you are saying that they should both cause errors? It appears that
inc1() only returns 'ctrl' and stops executing the function because
adding the following loop to the program (and commenting out function
'inc2') just prints a bunch of zeros.
for i = 1 to 10 do
? inc1()
end for
Bernie Ryan wrote:
>
>
>
> integer ctrl ctrl = 0
>
> -- THIS WILL PARSE AND WORK PROPERLY
> function inc1() return ctrl = ctrl + 1 end function
>
> -- THIS WILL NOT PARSE CAUSES AN ERROR at the +=
> function inc2() return ctrl += 1 end function
>
>
>
> Bernie
2. RE: BUG in EUPHORIA PARSER
I take it back... Function 'inc1' is just fine and returns zeros
because ctrl will never equal ctrl+1 (it is returning the result of a
comparison). Function 'inc2' errors because it doesn't make sense by
the definition of the language.
-- Brian
Brian Broker wrote:
> So you are saying that they should both cause errors? It appears that
> inc1() only returns 'ctrl' and stops executing the function because
> adding the following loop to the program (and commenting out function
> 'inc2') just prints a bunch of zeros.
>
> for i = 1 to 10 do
> ? inc1()
> end for
>
>
> Bernie Ryan wrote:
> >
> >
> >
> > integer ctrl ctrl = 0
> >
> > -- THIS WILL PARSE AND WORK PROPERLY
> > function inc1() return ctrl = ctrl + 1 end function
> >
> > -- THIS WILL NOT PARSE CAUSES AN ERROR at the +=
> > function inc2() return ctrl += 1 end function
> >
> >
> >
> > Bernie
>
>
>
3. RE: BUG in EUPHORIA PARSER
Sabal.Mike at notations.com wrote:
> This is not a bug. "return" needs an atom as a parameter.
> ctrl+=1 is an assignment, not an atom.
> ctrl = ctrl + 1 is a boolean expression that will always return 0
> (a number can never be one greater than itself). Try this:
>
> function inc(object o)
> return o+1
> end function
> -- remember that operators can work on both atoms and sequences.
>
> or on a global or file variable:
>
> function incg() -- assumes ctrl has already been defined and initialized
> return ctrl+1
> end function
>
> ctrl = incg()
>
> or if I want to program a shortcut function:
>
> function incg() -- see above
> ctrl+=1
> return ctrl
> end function
>
> for ctr = 1 to 10 do
> ? incg()
> end for
>
> or probably the best way to shortcut:
>
> procedure incg() -- note that this is a procedure, not a function;
> assumes ctrl
> ctrl+=1
> end procedure
> -- this is more Pascalesque.
> if some_condition then
> incg()
> end if
>
> HTH,
> Michael J. Sabal
Thanks Brian and Michael for the explaination.
I wasn't do what I though I was doing.
Bernie