Namepaces in Powershell

December 6, 2007

I was wondering, how we can organise the functions within namespaces in powershell.

I thought since we can create key-value pairs  in powershell, we should be able to use that for organising namespaces and with help of the powerful “&” we can evaluate the values of the corresponding keys.  so in the end the code we get what looks more javascripty.

so, we can organize the functions and variables in powershell within namespaces in the following manner :

namepaces_in_powershell_2

wow….I love this….looks more javascripty to me.. 🙂

I was also thinking that since “&”  is jus like an “eval” function in javascript, we can do something like this in powershell:

namepaces_in_powershell

I’ve not thought where exactly can i use them, but they look promising and at times could be very  handy 🙂

Now, i’m thinking how we can simulate polymorphic behavior 🙂

[updated: code formatting was messy, so i had to put that in an image for ease of readability.]