Skip to content

pub fn introduced to early? #546

Open
@timjs

Description

@timjs

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions