Skip to content

Commit efe5f3b

Browse files
celeroncoderForestry.io
authored andcommitted
Update from Forestry.io
Khushal Bhardwaj updated content/posts/functions-in-memory-stack.md
1 parent 7752921 commit efe5f3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

content/posts/functions-in-memory-stack.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ image = "/blog/uploads/function_in_stack.webp"
1111
+++
1212
Checkout my twitter thread explaining how functions work in memory (stack).
1313

14-
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Here&#39;s how functions behave in the stack (aka memory)<br><br>A thread 🧵<a href="[https://twitter.com/hashtag/programming?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/programming?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/programming?src=hash&amp;ref_src=twsrc%5Etfw")">#programming</a> <a href="[https://twitter.com/hashtag/DSA?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/DSA?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/DSA?src=hash&amp;ref_src=twsrc%5Etfw")">#DSA</a> <a href="[https://twitter.com/hashtag/ALGO?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/ALGO?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/ALGO?src=hash&amp;ref_src=twsrc%5Etfw")">#ALGO</a> <a href="[https://twitter.com/hashtag/recursions?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/recursions?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/recursions?src=hash&amp;ref_src=twsrc%5Etfw")">#recursions</a> <a href="[https://twitter.com/hashtag/stack?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/stack?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/stack?src=hash&amp;ref_src=twsrc%5Etfw")">#stack</a> <a href="[https://twitter.com/hashtag/memory?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/memory?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/memory?src=hash&amp;ref_src=twsrc%5Etfw")">#memory</a> <a href="[https://twitter.com/hashtag/functions?src=hash&amp;ref_src=twsrc%5Etfw](https://twitter.com/hashtag/functions?src=hash&amp;ref_src=twsrc%5Etfw "https://twitter.com/hashtag/functions?src=hash&amp;ref_src=twsrc%5Etfw")">#functions</a></p>&mdash; Khushal Bhardwaj (@CeleronCoder) <a href="[https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw](https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw "https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw")">September 19, 2022</a></blockquote> <script async src="[https://platform.twitter.com/widgets.js](https://platform.twitter.com/widgets.js "https://platform.twitter.com/widgets.js")" charset="utf-8"></script>
14+
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Here's how functions behave in the stack (aka memory)<br><br>A thread 🧵<a href="[https://twitter.com/hashtag/programming?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/programming?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/programming?src=hash&ref_src=twsrc%5Etfw")">#programming</a> <a href="[https://twitter.com/hashtag/DSA?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/DSA?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/DSA?src=hash&ref_src=twsrc%5Etfw")">#DSA</a> <a href="[https://twitter.com/hashtag/ALGO?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/ALGO?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/ALGO?src=hash&ref_src=twsrc%5Etfw")">#ALGO</a> <a href="[https://twitter.com/hashtag/recursions?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/recursions?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/recursions?src=hash&ref_src=twsrc%5Etfw")">#recursions</a> <a href="[https://twitter.com/hashtag/stack?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/stack?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/stack?src=hash&ref_src=twsrc%5Etfw")">#stack</a> <a href="[https://twitter.com/hashtag/memory?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/memory?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/memory?src=hash&ref_src=twsrc%5Etfw")">#memory</a> <a href="[https://twitter.com/hashtag/functions?src=hash&ref_src=twsrc%5Etfw](https://twitter.com/hashtag/functions?src=hash&ref_src=twsrc%5Etfw "https://twitter.com/hashtag/functions?src=hash&ref_src=twsrc%5Etfw")">#functions</a></p>— Khushal Bhardwaj (@CeleronCoder) <a href="[https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw](https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw "https://twitter.com/CeleronCoder/status/1571901815616344065?ref_src=twsrc%5Etfw")">September 19, 2022</a></blockquote> <script async src="[https://platform.twitter.com/widgets.js](https://platform.twitter.com/widgets.js "https://platform.twitter.com/widgets.js")" charset="utf-8"></script>
1515

1616
Things to keep in mind to understand functions behavior
1717

@@ -22,9 +22,9 @@ Here's a program with a main function that call some other functions and that fu
2222

2323
![](/blog/uploads/function_in_stack.webp)
2424

25-
When the function, completes execution the functions gets off the stack and the program returns to the previous program flow, aka to the previous function that called that function.
25+
When the function, completes execution the functions gets off the stack and the program returns to the previous program flow, aka to the previous function that called that function.![](/blog/uploads/stack_get_off_1.webp)![](/blog/uploads/stack_get_off_2.webp)
2626

27-
Now, there is nothing left in the stack, even the main function that is loaded by default, gets off the stack, the program finishes execution.
27+
Now, there is nothing left in the stack, even the main function that is loaded by default, gets off the stack, the program finishes execution.![](/blog/uploads/empty_stack_1.webp)
2828

2929
**Takeaways:**
3030

0 commit comments

Comments
 (0)