Skip to content

David Barreto's Blog

  • Home
  • Articles
  • Tutorials
  • Starknet
  • Projects
    • Addon
  • About Me

local

Cairo’s Local Variables Exercise I

11 July, 20227 July, 2022 by David Barreto

What’s wrong with the following code? (Hint: try to replace ap += SIZEOF_LOCALS with alloc_locals and see what happens) Can you fix it without changing the order of the variable definitions in the code?

func main():
    tempvar x = 0

    local y
    ap += SIZEOF_LOCALS
    y = 6
    ret
end

Read more

Categories Starknet Tags cairo, local, starknet, starkware, tempvar, variables Leave a comment
David Barreto

David Barreto

Developer Advocate at StarkWare with a Bachelor's degree in Electronics Engineering and a Master's degree in Systems Engineering. He is passionate about management, software development, blockchain, teaching, writing and discovering new technologies. He currently lives in Toronto.

View Full Profile →

Contact Me

If you want to get in touch with me, send me an email at barretollano@gmail.com

Find me on

  • LinkedIn
  • Twitter
  • YouTube

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 28 other subscribers

Top Articles

  • [Spanish] Usando pip con servidores alternativos
    [Spanish] Usando pip con servidores alternativos
  • Integrating Docker Sandbox with OpenCode and Venice
    Integrating Docker Sandbox with OpenCode and Venice
  • [Spanish] Curso de AWK
    [Spanish] Curso de AWK
  • Introduction to the Typescript Transpiler
    Introduction to the Typescript Transpiler
  • Account Abstraction on Starknet, Part III (Repost)
    Account Abstraction on Starknet, Part III (Repost)
© 2026 David Barreto's Blog • Built with GeneratePress