Skip to content

Namespaces

November 7, 2009

ok I mentioned before that I’ve implemented namespaces in my quantity system

Why I’ve made this ??

because simply I wanted to add the possibility of adding multi functions in a form of external libraries.

Namespace Operator or Separator

  1. in C++ the name space is two colons :: like the famous std::vector
  2. in C# the namespace is a dot . like  System.Console.WriteLine
  3. in xml the namespace is single colon :

so I’ve choose the xml namespace operator because I find it shorter than C++ namespace and more understandable than the dot of C#.

because I’ve always considered the dot .  to separate between the object and its members

Built in Functions

like any respectable language you have some built in library for mathmatical functions

you can find the functions and constants to be used 🙂

I’ve defined Math namespace to hold some (but not all) functions

Math:Sin, and Math:Sinh

Math:Cos, and Math:Cosh

Math:Log, and Math:Log10

and Math:PI  as a constant

 

User Defined Functions

you can define your user defined function in any namespace you desire

just write the namespace:function  and suddenly you have a new namespace if it wasn’t there before 😀

Qs> G:V(x,y) = x(y)   # function that take other function as a parameter

Qs> g:v(Math:Sin, 8 )  # passing built in sin function with 8

 

and as you can notice the functions and namespaces are all case insensitive.

 

User Defined Functions (External Modules)

and yes you can define your functions outside the quantity system

but the feature is not completed yet

however please try

Qs> Music:Play(c d e f g a b c>)

if you hear the music from your speaker then you are a windows guy 😀

and you can save this as a midi file too 😀

Qs> Music:SaveMidi(c d e f g a b c>, tt.mid)

please find the result file into the program directory.

 

 

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: