#Proper Name for Entities (the zig way)

1 messages · Page 1 of 1 (latest)

obsidian mist
#

Hello, I'm new to zig and have a question regarding (official or unofficial) naming conventions:
How are function names for libraries named, with a verb as prefix?

I am building a zig gui library that is specific for Apple operating systems and am now struggling to name the ui entities the zig way.
Normally I'm totally fine with this:

Application
Window
Button
etc.

But it could be that the zig way must be a different style like:

newApplication
newWindow
newButton
etc.

or:

createApplication
createWindow
createButton
etc.

or:

zApplication
zWindow
zButton
etc.

Any hint how to do it the zig way is appreciated.
Thanks.

brave scroll
#

Roughly speaking: camelCaseFunctionName, TitleCaseTypeName, snake_case_variable_name. More precisely:
If x is a type then x should be TitleCase, unless it is a struct with 0 fields and is never meant to be instantiated, in which case it is considered to be a "namespace" and uses snake_case.
If x is callable, and x's return type is type, then x should be TitleCase.
If x is otherwise callable, then x should be camelCase.
Otherwise, x should be snake_case.
https://ziglang.org/documentation/master/#Style-Guide

#

Just follow this depending on the types of the things you expose

obsidian mist
#

Thank you for your quick response.
Reading the Style-Guide it looks like verbName for a function name is only used when the return is a "normal" value not a struct.
If the return type is a struct, then TheName seems the appropriate zig way to name a function.
Thanks again 😄