If you think that’s bad take a look at this real code posted as a real issue on one of my Github repos, which was described as quite short
Oh yea, that's the good stuff **huffs glue**
Submitted 1 year ago by tatterdemalion@programming.dev to programmer_humor@programming.dev
https://programming.dev/pictrs/image/7580c3d3-7ca2-4e98-b60d-e0b1abf25015.png
Comments
jeffhykin@lemm.ee 1 year ago
parlaptie@feddit.de 1 year ago
That’s not actual code though, it looks like some kind of trace. Notice the filenames at the end of each line.
jeffhykin@lemm.ee 11 months ago
Without thinking about it much, my understanding was that each line of the stack trace referred to a real line, even though the block as a whole wasn’t a program.
But! because of this comment I went and checked the lines of those stack traces. And in fact, they’re not real lines, just the C++ type expansion.
That said I’ve got a another half as bad example that is real so Ive edited the comment to point to that example instead.
MurdoMaclachlan@lemmy.world 1 year ago
Image Transcription:
type Wtf = Option>>>>>>>; let two = Some(Some(Some(Some(Some(Some(None)))))); let three = Some(Some(Some(Some(Some(None))))); let six = Some(Some(None)); unsafe { assert_eq!( std::mem::transmute::(two) * std::mem::transmute::(three) std::mem::transmute::(six) ); }
I am a human who transcribes posts to improve accessibility on Lemmy. Transcriptions help people who use screen readers or other assistive technology to use the site. For more information, see here.
pkill@programming.dev 1 year ago
Good human, but why not use tesseract though? I mean it works quite well with monospace fonts
MurdoMaclachlan@lemmy.world 1 year ago
Still needs to be checked over to make sure it didn’t get anything wrong. In my experience the mistakes AI make with monospace fonts tend to be very awkward to notice (like 1 and l and I and | being interchanged), so I’d have to go over with a fine tooth comb which, for me, since I type quickly, isn’t noticeably faster and is a lot more boring.
Oha@lemmy.ohaa.xyz 1 year ago
Good Human
errer@lemmy.world 1 year ago
loud suicide noises
gsfraley@lemmy.world 1 year ago
For those interested, this is because of how Rust uses value gaps to represent its nullable/enum structures. E.g., like how
None
forOption
[sic] is represented internally by a0
instead of a wrapping structure.When you have that many layers around a unit, it will start at
0
and bump the internal representation for eachSome
you turn into aNone
.Hack3900@lemy.lol 11 months ago
It’s kinda like lambda calculus numbers
Fargeol@kbin.social 1 year ago
Is that a Peano Axioms reference ?
https://en.wikipedia.org/wiki/Natural_number#Peano_axiomsparlaptie@feddit.de 1 year ago
It’s somehow inverted. If it was Peano, two would be represented by two Somes, not by six. I have no idea how this one works.
baseless_discourse@mander.xyz 1 year ago
Knusper@feddit.de 1 year ago
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.baseless_discourse@mander.xyz 1 year ago
Fin
is a type of finite oridinals bounded by a int. For example the WTF 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, or like you suggest use a fixed length array with unit (not number) as components.
However for
Fin
, the input number is dynamic, hence it represents the type of finite ordinals. For example, it was able to type the fact that nth fibonacci number is a finite ordinal bounded by a function of n. Which I believe is not typable in rust?
mvirts@lemmy.world 1 year ago
And yet still more better than writing a serious macro
subignition@fedia.io 1 year ago
Definitely looks
unsafe
to me.