Already from the very first exercise, learners are asked to write functions using pub fn instead of just fn, although the meaning of pub will only be clear after the third exercise where modules are introduced. Sadly, this can cause confusion.
I experienced this confusion with my own students. They say "I understand that fn means "function", so it introduces a new function, but what is the pub for?" This is actually an old didactic problem which also arises when teaching Java, where newbies are forced to write public static void main() {...} without knowing what all these keywords are for. (And it is way to difficult to explain all of them in the first few lectures on Java programming.)
I can guess the need of writing pub fn is to be able to run the tests. However, would it be possible in any way to circumvent this for the sake of didactics? Maybe with a preprocessing step where we simply substitute ^\s*fn with ^pub fn before running the tests?
Already from the very first exercise, learners are asked to write functions using
pub fninstead of justfn, although the meaning ofpubwill only be clear after the third exercise where modules are introduced. Sadly, this can cause confusion.I experienced this confusion with my own students. They say "I understand that
fnmeans "function", so it introduces a new function, but what is thepubfor?" This is actually an old didactic problem which also arises when teaching Java, where newbies are forced to writepublic static void main() {...}without knowing what all these keywords are for. (And it is way to difficult to explain all of them in the first few lectures on Java programming.)I can guess the need of writing
pub fnis to be able to run the tests. However, would it be possible in any way to circumvent this for the sake of didactics? Maybe with a preprocessing step where we simply substitute^\s*fnwith^pub fnbefore running the tests?