this post was submitted on 15 Nov 2023
233 points (97.6% liked)
Programmer Humor
19551 readers
772 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Is this how you do Fin in peasant languages?
No, not at all. It's a joke post, abusing the in-memory representation of the
Option
type to construct numbers. When nesting theOption
type, it turns into a densely packed bit vector...And if I understand the purpose of
Fin
correctly, you're picking on the one 'peasant language' that actually has something like that built-in.In Rust, you can specify the type of an array as e.g
[u8; 3]
. Which is an array containing values of typeu8
(unsigned 8-bit integer) with a fixed, compile-time-guaranteed length of3
. So,[u8; 3]
could be used to represent an RGB color, for example.It is an array, not a set, but well, close enough.
Fin
is a type of finite oridinals bounded by a nat. For example theWTF
type in there is the same type asFin 8
.Of course every language can have
Fin
with a fixed integer, like the post suggest, by just stacking options.However for a properly defined
Fin
type, the input number is dynamic, serves as a bound for the element of the type. For example, Adga was able to type the fact thatn
th fibonacci number is a finite ordinal bounded by a function ofn
. Which I believe is not typable in rust?