Author Topic: Sub in a Sub???  (Read 8140 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Sub in a Sub???
« Reply #15 on: September 09, 2008, 07:00:52 PM »
0
Well recursion would call subs from subs, and recursion can do in a very small amount of code what would take many lines to accomplish.  However since gosubs are more cpu intensive than other activities, recursion ( I believe ) would become very slow in easyuo very fast.  Never actually run tests with it in easy uo, just remembering little programs I played with back in the day.

It's all relative really.  Since EUO execution is tied to #LPC (lines per cycle) then it really takes the same amount of time to execute a "gosub" as it does to execute a "sub".  Now if we were talking assembly language, then you'd have the higher ground since you will then be talking about CPU cycles and not time as Timex watches count.

My CLAw looter utilized a pretty intense recursive loop to look through all the possible loot rules and this loop scales pretty linearly.  For sure it's a bit more CPU intensive but who knows by how much ( do know it's pretty small increase)

I'd love to see someone actually quantify this since I'd love to compare it to how ScriptUO handles recursion.  :)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Sub in a Sub???
« Reply #16 on: September 10, 2008, 03:00:24 AM »
0
One other little tidbit about EasyUO and recursion is that most people might not realize is that recursive calls to subroutines with a "FOR" statement won't work as you might expect.  EasyUO handles the iterative argument of a FOR loop separately than a normal variable.  So if you have any looping constructs, you must not use FOR loops to be safe.  I know it fails with !vars, which indicates that when Cheffe implemented 1.5 of EasyUO, he didn't update the FOR construct for those who might be using namespace variables. 

I'll have to think of a small snippet to demonstrate why it doesn't work..
« Last Edit: September 10, 2008, 03:29:53 AM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: