Oxygen Basic

Information => Open Forum => Topic started by: Peter on March 03, 2011, 02:30:13 PM

Title: Lazy evaluation
Post by: Peter on March 03, 2011, 02:30:13 PM
Deleted
Title: Re: Lazy evaluation
Post by: Charles Pegge on March 03, 2011, 04:54:47 PM
Hi Peter.
I am glad to say we already have it  8)

It is a very simple implementation in the expressions() function which compiles all expressions (except metacode).

from src/o2expr.bas
Code: [Select]
 '
  '----------------
  'LAZY EVALUATIONS
  '================
  '
  if (nst=0)and(cnd<>0) then
    skiplspace(s,i)
    if (asc(wr)=rbr)and(stk.c=0)and(ascn=lbr) then
      '
      '
      'IF (A)AND(B) THEN ... always fail
      '---------------------------------
      '
      if op=33 then
        wt+="or "+qeax+cm+qeax+stp+"jz fwd _cnd"+cr
      end if
      '
      'IF (A)OR(B) THEN .. always succeed
      '----------------------------------
      '
      if op=34 then
        wt+="or "+qeax+cm+qeax+stp+"jnz fwd _cnd"+cr
      end if
      '
    end if
  end if
  '
  goto oploop
  '
  '

Charles