NASA's 11th rule: All forms of indirection must indirect 12 times. This is not an upper or lower bound. This is the exact number of indirections. Why? F*** you, that's why.
Yeah, but in computing (well, specifically the language this slide is about) they're referred to as integers and not referred to as "whole numbers" or any other synonym. If you're looking up something to do with integers in the documentation, you need to have the word "integer" in your vocabulary as "the" way to refer to numbers without decimal places to find what you're looking for. Same way you need to know "string" instead of "word" or "text field" or "sentence".
actually, you can even store pointers to nothing in memory. you just do:
void x;
void* x_ptr = &x;
then you can use it to invoke functions that take no arguments like this:
void open_texteditor (void editor_choice)
{
// do nothing with the editor_choice because there is only one sensible editor
open_nano();
return void;
}
void favorite_texteditor;
void result = open_texteditor(favorite_texteditor);
print_error_on_bad_result(result);
Yes. It converts ... well, any data type, really, to an int, and then you can do math on that value, via the normal Python syntax.
My point was that Int() is pre - formed... the author of this slide here is hopefully, before they switch to the next side, asking the classroom if there is anything wrong with their slide.
Small spelling errors are often trvial in written language, but uh... they're kind of a very big deal in code.
You... could make a function that directly does some math operations on a string.
You could try to set up a bitshifting scheme, you could essentially make FancyMathInt(x,y), where x is converted to an int, and, perhaps hilariously, y is a string of math operations done to x, after y itself is parsed and converted to an instruction set...
There's a lot of ways you could do that.
... Most of them are probably stupid, but, niche edges do sometimes arise where something like that could be useful.
You can very much perform calculations on strings, and its a very cool thing, but i think thats wayyy above the level that this presentation is meant for cause you probably should know what integers are before that, even outside of programming...
29 Comments
sunoc@sh.itjust.works · 74 pts · 265d
Laugh in C
JusticeForPorygon@lemmy.blahaj.zone · 33 pts · 265d
Imagine having strings
sunoc@sh.itjust.works · 32 pts · 265d
You mean arrays of chars ?
Atlusb@lemmy.world · 11 pts · 265d
What about a pointer to a series of pointers which point to chars?
a_non_monotonic_function@lemmy.world · 5 pts · 264d
NASA's 11th rule: All forms of indirection must indirect 12 times. This is not an upper or lower bound. This is the exact number of indirections. Why? F*** you, that's why.
anton@lemmy.blahaj.zone · 9 pts · 265d
renzhexiangjiao@piefed.blahaj.zone · 60 pts · 265d
they are known as integers outside of computing too lol
pory@lemmy.world · 11 pts · 264d
Yeah, but in computing (well, specifically the language this slide is about) they're referred to as integers and not referred to as "whole numbers" or any other synonym. If you're looking up something to do with integers in the documentation, you need to have the word "integer" in your vocabulary as "the" way to refer to numbers without decimal places to find what you're looking for. Same way you need to know "string" instead of "word" or "text field" or "sentence".
zqwzzle@lemmy.ca · 50 pts · 265d
JavaScript trying to look nonchalant in the corner.
orockwell@lemmy.world · 8 pts · 265d
Type coercion
jia_tan@lemmy.blahaj.zone · 20 pts · 265d
More like type mutilation
a_non_monotonic_function@lemmy.world · 4 pts · 264d
Depression.
genuineparts@sh.itjust.works · 25 pts · 265d
Amazingly you can store all sorts of things in variables.
ThunderComplex@lemmy.today · 13 pts · 265d
Including nothing. Actually, depending on the language, multiple types of nothing (null vs uninitialized)
ICastFist@programming.dev · 7 pts · 264d
This has made a lot of people very angry and been widely regarded as a bad move.
gandalf_der_12te@discuss.tchncs.de · 6 pts · 264d
actually, you can even store pointers to nothing in memory. you just do:
then you can use it to invoke functions that take no arguments like this:
(note that this is a joke comment)
dandelion@lemmy.blahaj.zone · 22 pts · 265d
comp sci brainrot
sp3ctr4l@lemmy.dbzer0.com · 20 pts · 265d
I mean, in Python, Int() literally is a pre - formed function for per - forming math on strings.
rumschlumpel@feddit.org · 17 pts · 265d
IIRC int() doesn't let you do math on strings, it converts strings into integers and then you can do math with those numbers.
sp3ctr4l@lemmy.dbzer0.com · 1 pts · 265d
Yes. It converts ... well, any data type, really, to an int, and then you can do math on that value, via the normal Python syntax.
My point was that Int() is pre - formed... the author of this slide here is hopefully, before they switch to the next side, asking the classroom if there is anything wrong with their slide.
Small spelling errors are often trvial in written language, but uh... they're kind of a very big deal in code.
You... could make a function that directly does some math operations on a string.
You could try to set up a bitshifting scheme, you could essentially make FancyMathInt(x,y), where x is converted to an int, and, perhaps hilariously, y is a string of math operations done to x, after y itself is parsed and converted to an instruction set...
There's a lot of ways you could do that.
... Most of them are probably stupid, but, niche edges do sometimes arise where something like that could be useful.
Treczoks@lemmy.world · 11 pts · 265d
This is programming 101 from which century?
spujb@lemmy.cafe · 1 pts · 265d
does it say programming 101 somewhere
Rooster326@programming.dev · 2 pts · 264d
No programming 101 is what happens when you perform calculations on a string.
Please do try to keep up.
spujb@lemmy.cafe · 0 pts · 264d
oh i see we are just being judgmental for fun my fault for assuming it was genuine :(
Rooster326@programming.dev · 3 pts · 264d
It is only a joke.
Calculations on strings are "allowed".
"10" + "1" = "101"
AI_toothbrush@lemmy.zip · 8 pts · 263d
You can very much perform calculations on strings, and its a very cool thing, but i think thats wayyy above the level that this presentation is meant for cause you probably should know what integers are before that, even outside of programming...
ArtVandelay@lemmy.world · 4 pts · 263d
"preform calculations"
AnUnusualRelic@lemmy.world · 3 pts · 264d
Is it all right to postform calculations on a string?
TootSweet@lemmy.world · 2 pts · 264d
I can't let you do that, Dave.