Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>> The use of ' as a symbol that has any meaning on it's own has got to be one of the most stupid choices I've seen in a language.

' has a long history of use for various purposes in programming language syntax not derived from C.

In Ada, attributes are a single quote followed by the attribute name.

If I have an enum called Fruit then Fruit'First would give the first value in the Fruit enum definition.

http://www.ada-auth.org/standards/22rm/html/RM-4-1-4.html

Attributes provide meta information about types and are very useful when working with custom integer types and ranges:

https://learn.adacore.com/courses/advanced-ada/parts/data_ty...

Using ' for Rust lifetimes or Ada attributes is just a sigil https://en.m.wikipedia.org/wiki/Sigil_(computer_programming)

It is not too different from:

    & for addresses / references in C, C++, and Rust, 

    * for dereferencing in C, C++, and Rust  

    $ for value substitution in shells and scripting languages

    : to mark keywords in Clojure and some Lisps


It may not be too different from references, but Rust separately has those also, separately from lifetimes.

In modern languages, we don't have to think about lifetimes most of the time, let alone notate them.

Rust has too much stuff converging into the same context.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: