Seems Swift has no way to namespace functions aside from methods on data structures. Seems too OO; maybe I missed something?
Conversation
Yes, static funcs on structs is typical practice now. I imagine we’ll get qualified imports eventually.
1
Thanks Andy, I appreciate the response :) Might it be more preferable to use enums instead of structs if there's no data?
1
Don’t think it matters in terms of codegen, if we’re talking static funcs.
1
I hadn't thought of codegen. Pedantic, but looks like the enum generates ~8 lines fewer SIL code, and maybe avoids an alloc.
1
Replying to
Why would there be an alloc? We’re talking about static methods, yeah?
Replying to
No idea, but I don't pretend to have a passing knowledge of SIL. (In Assembly, struct is less code.)
2
Comes from this, and compiled with "swiftc struct.swift -emit-sil".

