Skip to content

David Barreto's Blog

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

variables

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 27 other subscribers

Top Articles

  • Directive Inheritance in AngularJS
    Directive Inheritance in AngularJS
  • How to Use Typescript with SystemJS
    How to Use Typescript with SystemJS
  • Redux Form Validation with ngrx-forms
    Redux Form Validation with ngrx-forms
  • Cario's Reassigned and Revoked Reference Example
    Cario's Reassigned and Revoked Reference Example
  • Google Apps Script Local Development Tutorial
    Google Apps Script Local Development Tutorial
  • Cairo's Relative Jump Exercise
    Cairo's Relative Jump Exercise
  • Cairo's Polynomial Exercise
    Cairo's Polynomial Exercise
  • [Spanish] Cómo establecer los permisos de la carpeta www en Ubuntu
    [Spanish] Cómo establecer los permisos de la carpeta www en Ubuntu
  • Infrastructure as Code with AWS CDK
    Infrastructure as Code with AWS CDK
  • Updating Python on macOS
    Updating Python on macOS
© 2026 David Barreto's Blog • Built with GeneratePress