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

  • How to Use Typescript with SystemJS
    How to Use Typescript with SystemJS
  • Four Challenges to StarkNet’s Success
    Four Challenges to StarkNet’s Success
  • Cairo’s Implicit Arguments Exercise
    Cairo’s Implicit Arguments Exercise
  • [Spanish] El misterio del error de precisión de los números de punto flotante
    [Spanish] El misterio del error de precisión de los números de punto flotante
  • Introduction to the Typescript Transpiler
    Introduction to the Typescript Transpiler
  • The Probabilities of Breeding Pure Axies
    The Probabilities of Breeding Pure Axies
  • Configuring Webpack with Typescript
    Configuring Webpack with Typescript
  • Optimize your Angular 2 Application with Tree Shaking
    Optimize your Angular 2 Application with Tree Shaking
  • StarkNet ERC721 Workshop: Exercise 6
    StarkNet ERC721 Workshop: Exercise 6
  • [Spanish] ¿Cómo le explicarías el funcionamiento de Bitcoin a un niño?
    [Spanish] ¿Cómo le explicarías el funcionamiento de Bitcoin a un niño?
© 2026 David Barreto's Blog • Built with GeneratePress