Author Topic: Understanding namespace interaction  (Read 11752 times)

0 Members and 2 Guests are viewing this topic.

Offline UOMaddog

  • Maddog
  • Elite
  • *
  • *
  • Posts: 1620
  • Activity:
    0%
  • Reputation Power: 22
  • UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...
  • Gender: Male
  • Biggest B@D@$$ of the Universe
  • Respect: +165
  • Referrals: 8
    • View Profile
    • My Website
Re: Understanding namespace interaction
« Reply #15 on: September 05, 2009, 12:22:02 PM »
0
"Namespaces" really are EUO's way of implementating a sort of "stack". In most programming languages (I'll use C as an example), you can call a function to do something to data you pass it, or you can have it return a value to you, or both.

At the Operating System level, when you call a function, you are basically putting any data you're giving it onto the "stack" and telling the function where you put it. When control is handed over to the function, the very first thing is does is make a copy of the variables it was passed so that it can play around with them without corrupting the original values. Essentially it's creating it's own "namespace" where it can play around with "x, y, z, etc" as much as it wants without changing their original values.

After the function completes, it will then "pop" the new values back onto the stack and officially change those values UNLESS some sort of error occurs! That's the beauty of it! Since it's not changing the actual values, if an error occurs, the function can hand control of the program back to whatever called it and say "Oh yea, btw, something was all screwed up so I couldn't do what you wanted" and hands back the original values.

Now this is a very watered-down version of what happens, because it all depends on the error controls of the function. Some functions may return the original values as well as the messed up values so that you can analyze what went wrong. There are many other possibilities, but you get the general idea.

So here's a quick summary of namespaces:

Quote
Person 1:
"Hey, I need you to take a look at something and figure something out"

Person 2:
*looks at what person 1 is showing him and jots it down on his own sheet of paper*

Person 1:
*waits patiently while person 2 is working*

Person 2:
"Hey, I did what you wanted, here it is!"
*writes down the results on person 1's original paper*

Person 1:
"Thanks!"
*take his results and goes to do whatever with them*

Now, EUO is a very BAD implementation of this! gosub's are supposedly "functions" but arguments are not passed the same way as they would be in any other scripting language. Type's are pretty much non-existent in EUO. There is no difference between numbers, strings, arrays, or anything else. And let's not even get started with pointers. I guess the moral of this story is, don't ever model anything after EUO!!
There are 10 kinds of people in this world: those that understand binary and those that don't!

Windows:  A 64-bit tweak of a 32-bit extension to a 16-bit user interface for an 8-bit operating system based on a 4-bit architecture from a 2-bit company that can't stand 1 bit of competition!

Offline OMGBurgers

  • Hero Member
  • *
  • Posts: 785
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Understanding namespace interaction
« Reply #16 on: March 23, 2011, 02:50:30 PM »
0
Edited -

I didn't fully understand push/pop and I think that's what was screwing me up.

I was under the assumption you needed to save your namespace variables with push, but you don't.
Push simply stores/saves the CURRENT namespace name/type, as tm said in his post "Remembers", or easyuo wiki says "stores ....... in an internal stack".
Pop simply restores/sets/whatever the current namespace to whatever namespace name/type is "remembered"/"stored internally". (?)


namespace local main   ;sets current local/main
namespace push   ;stores local/main
namespace local setup   ;sets current local/setup
namespace push   ;stores local/setup
namespace local scan   ; sets current local/scan
namespace clear   ;cleares current namespace local/scan
namespace pop   ;restores current namespace to local/setup
namespace clear   ;cleares current namespace local/setup
namespace pop   ;restores current namespace to local/main

I thought that easyuo wouldn't be able to pop twice, to restore the main namespace, but it does.  I suppose it kinda "queues" namespaces in a "list", as you push namespaces, they go to the top of the "list", when you pop a namespace, it restores the namespace on the top of the "list", removes it from "queue", and you can continue to pop, until your "list" of "queued" namespaces has been depleted.


I hope that makes sense to anyone, and is now correct... lol
« Last Edit: March 23, 2011, 03:26:31 PM by OMGBurgers »

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 12920
  • Activity:
    0.8%
  • Reputation Power: 150
  • 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: +1328
  • Referrals: 32
    • View Profile
    • ScriptUO
Re: Understanding namespace interaction
« Reply #17 on: March 23, 2011, 03:40:09 PM »
0
Really it's more like a stack (i.e. push/pop), but I think you get it.  ;)

http://en.wikipedia.org/wiki/Stack_%28data_structure%29
« Last Edit: March 23, 2011, 03:47:05 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline OMGBurgers

  • Hero Member
  • *
  • Posts: 785
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Understanding namespace interaction
« Reply #18 on: March 23, 2011, 04:06:47 PM »
0
makes sense!

i guess thats where the "internal stack" comes from, as described on the easyuo wiki.

once i understood how push/pop worked, it's been easier.  especially when i found those namespace variables that store current namespace, and current namespace type! lol

Offline Pearls

  • Elite
  • *
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Understanding namespace interaction
« Reply #19 on: July 02, 2014, 06:15:46 AM »
0
Thanks :) Pretty easy in theory hehe :D
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 12920
  • Activity:
    0.8%
  • Reputation Power: 150
  • 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: +1328
  • Referrals: 32
    • View Profile
    • ScriptUO
Re: Understanding namespace interaction
« Reply #20 on: July 02, 2014, 10:16:42 AM »
0
There's no data structures in EUO, so this is really the closest you can get.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Pearls

  • Elite
  • *
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Understanding namespace interaction
« Reply #21 on: July 02, 2014, 10:43:56 AM »
0
There's no data structures in EUO, so this is really the closest you can get.

And... now you've lost me haha :D
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "