asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

Case convention for the standard library #88

Open perimosocordiae opened 2 years ago

perimosocordiae commented 2 years ago

Right now the code in stdlib/ contains a mishmash of styles, with UpperCamelCase and snake_case most predominant. We should decide on a common case convention for:

I don't have a concrete proposal yet, but here are some miscellaneous thoughts on the topic:

Finally: whatever convention we decide to follow for stdlib code is very likely to become the convention for all Icarus code. We should do our best to make it readable, convenient to use, and easy to remember.

asoffer commented 2 years ago
  • As of now, reserved keywords are almost entirely single-word lowercase. If we use UpperCamel it's very clear what is a keyword and what is user-defined.

I think we should consider this a non-concern. Builtins do not need to prime syntactic real estate. Zig prefixes them with @. C++ prefixes them with underscores. I don't think ours will be as hidden as they are in C++, but nevertheless, they should take a backseat to library code.

asoffer commented 2 years ago

Naming conventions, some common, some I just made up for this post, so we have a language with which to talk about these options.

Thoughts:

perimosocordiae commented 2 years ago

One category that I forgot about in my initial list: module names. We currently use snake_case for modules, but this runs the risk of name clashes (especially for constructions like c ::= import "c/stdio.ic"). I know that technically modules are just values like everything else, but a syntactic distinction may be useful.

asoffer commented 2 years ago

I suspect it will be rare for the standard library to export modules, so the naming convention here shouldn't matter too much. That being said, I'd like to aim for the standard library to be readable just like "normal code" and so it's possible that whatever conventions we choose will be copied.

In my mind the bigger concern is that modules will be spelled frequently and should therefore be unobtrusive. If we make them annoying to spell (e.g., something horrible like RoLlErCoAsTeRcAsE, users will opt for embedding the module with -- ::= import "xyz". This isn't as horrible as using namespace in C++, but it still probably produces a worse reading experience in most cases.