programming

how xaml handles children

this dude wrote a xaml compiler for mono

http://mono.myrealbox.com/source/trunk/mcs/tools/xamlc/README

i was wondering how they handled the parent-child relationship. xml is terrible and was never designed for such things (we can fight about this statement later).

my solution from gbscript (gamebasis's declarative language) was this..

Code:

result=new Window(wide=100,tall=100)
{
  childs+=new Button(text="one")
  {
  }

  childs+=new Button(text="two")
  {
    text_color=new Color3f(0,0,0);
  }
}


the very special feature is the concept of a "constructor" omg. which is a pretty important thing in oo languages. children are handled by "overloading" the += operator to mean.. append. if this was D stlye it would be a '~='. also notice how you can just set properties directly (text_color) with an implied this (i also had some other cool scoping concepts).. all the goodness you need and very clean and very simple to parse and execute. i've used this for ui, for scripting code, for configurations, for file formats, serialization, even for network communication. (gbscript also optionally blended into it seemlessly)

now compare that to the disgustingness of xaml using xml. ick.

however. i'll probably end up using xaml for the next project. an awesome format just does not win against a good format + tools.