Skip to content

Comments and some issues mainly about the documentation. #159

@ananashawaw

Description

@ananashawaw

Heya, I've just read the documentation on the website and a few elements seemed odd / outdated :

1. Optional?

firstly, there seem to be a misunderstanding between
option type :

type 'a option = 
| None
| Some of 'a

And
result type :

type ('a, 'e) result = 
| Ok of 'a
| Error of 'e

While the two may seem similar ; they are both well defined, especially option type, and, as such, reading that an "option type" could hold a value when it's empty was really confusing.

Furthermore, a very important specificity of option type is that you can nest them, however, from the documentation alone (I did not test this, so I may be wrong), it appears that c3 doesn't allow it ?

Unwrapping an Optional is safe because it checks it has a result present before trying to use it.
After unwrapping, the variable then behaves like a normal variable, a non-Optional.

Lastly, the notation type? is confusing, not only because it is easy to miss, but also because it usually denonate nullable types

2. There are also a few things that seem outdated about C :

2.1. Octal

The documentation states :

Octal removed
The old 0777 octal syntax is removed and replaced by a 0o prefix, e.g. 0o777. Strings do not support octal sequences aside from '\0'.
C has removed this from the language a few months ago already through this paper that was integrated in C2Y in october of last year

2.2 Generics

This page states that C doesn't have generics
But, C does, what it lacks is parametric polymorphism which seems to be what C3 uses from a quick glance.

2.3 Binary prefix

The feature page states that binary prefix is added by C3,
This isn't the case anymore since C23

2.4 Type Inference

The feature page mentions that c3 added type inference,
but, it is present in C23, the keyword is auto instead of var
The documentation is available at section 6.7.10 of the C standard.

3. Other comments I have :

3.1. Goto and Defer coexistance :

the documentation states

Rationale: It is very difficult to make goto work well with defer and implicit unwrapping of optional results. It is not just making the compiler harder to write, but the code is harder to understand as well. The replacements together with defer cover many if not all usages of goto in regular code.
The C wg has been discussing this issue for a while now, many pointers as to how to integrate it could be found on their website.
There already are some implementations of defer in C and they manage to work around goto.

3.2 Unicode

While I personally do not advocate for it, as I do not need it ;
The comment

The main argument for unicode identifiers is that “it allows people to code in their own language”. However, there is no proof that this actually is used in practice.
Did surprise me quite decently.
Indeed, as a foreigner, throughout the years, I have always, without fail, seen people use non ascii characters in languages that allow them.
I'm also doubtful that a search of repo manager such as github wouldn't come up with a very quantitative amount of proof for it.
As such, I don't think it is valid to state it is a "lack of actual proven benefit".
But, I can understand why the difficulty of implementation is a barrier in itself.

3.3 Wrong operator used for optional.

The features page says :

Optional types are formed using the ! suffix.
Isn't it ? instead, with ! being used for unpacking

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