Author Topic: Lazy evaluation  (Read 1729 times)

0 Members and 1 Guest are viewing this topic.

Offline StrangeQuark

Lazy evaluation
« on: November 14, 2002, 07:18:38 PM »
I was wondering, does the interpreter use lazy evaluation for logic statements or not?
I'll prolly never need this, but you never know.

(should I explain 'lazy evaluation')



Offline Nick Sonneveld

Re:Lazy evaluation
« Reply #1 on: November 15, 2002, 02:32:51 AM »
ok, I looked up lazy evaluation and I *think* it means if you have a function, it only evaluates the arguments when it needs it.

AGI's cmds only accepts constants or variable addresses so it doesn't really need to decide whether or not to evaluate something.

if you have something like addv(v10, v50+v20);  (which you can't do in the current compiler, but you can in my compiler), the compiler doesn't know if the command will need it or not (well,  it's a safe bet it does)  so it evaluates all arguments.

However, if you have something like if (f10 | f50 | f40) and f10 is true.. then the interpreter won't bother evaluating the rest of them.  it just automatically skips them.

umm.. I hope that helped.

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline StrangeQuark

Re:Lazy evaluation
« Reply #2 on: November 15, 2002, 05:50:59 AM »
Yep, that's exactly what I meant.
I'm learning Java for the moment and it's very useful for preventing those irritating ArrayIndexOutOfBoundsExceptions. They're pure evil!

[edit]And a big thank you to you, sir![/edit]
« Last Edit: November 15, 2002, 05:51:35 AM by CESS.tk »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.148 seconds with 20 queries.