in one file:
... some gui code
button -c "somefunction();"
... some more gui code that shows the gui
in some other file, presimably named somefunction.mel if not must be sourced seprately
global proc somefunction(){
print "something";
}
So:
A) guis dont need to know in advance what functions exist, they just eval strings.
B) fucntions will need to be loaded somehow for them to be called, if they arent loaded maya will TRY to fetch them form a appropriate file with same name as the function in question and look for a global proc of that name in the file. It does so by sourcing the file and then calling the function.
C) you gui can call nonexistent functrions, it does not matter for the builder. The error gets just dsplayed once the eval string f the gui item fails. Untill then its just text.