Function restrictions

If I load this from a script it works:

dwact: ([act:`d`k`ki]dsc:(“D”;“K”;“KI”));

`:db/dwact set dwact;

dwstat: ([stat:`p`s`e]dsc:(“P”;“F”;“E”));

`:db/dwstat set dwstat;

dwlog: (act:dwact$();stat:dwstat$();start:datetime$();end:datetime$();err:();note:());

`:db/dwlog set dwlog;

If a try to put it in a function like this it fails:

main:{

 dwact: ([act:`d`k`ki]dsc:(“D”;“K”;“KI”));

 `:db/dwact set dwact;

 dwstat: ([stat:`p`s`e]dsc:(“P”;“F”;“E”));

 `:db/dwstat set dwstat;

 dwlog: (act:dwact$();stat:dwstat$();start:datetime$();end:datetime$();err:();note:());

 `:db/dwlog set dwlog;}

main

Could somebody explain to me please why (I do have a one space indentation)?

Also could I be pointed to some links that explains clearly what can and what can’t go inside of a function?

The tutorials seem to forget to mention all sort of pretty annoying limitations, that I seem to run into, related to what you can use and what you can’t use inside a function.