impcore variable definition
play

Impcore variable definition Example (val n 99) Compare int n = - PowerPoint PPT Presentation

Impcore variable definition Example (val n 99) Compare int n = 99; Also, expressions at top level (definition of it ) Impcore expressions No statements means expression-oriented: (if e1 e2 e3) (while e1 e2) (set x e) (begin e1 ... en) (f


  1. Impcore variable definition Example (val n 99) Compare int n = 99; Also, expressions at top level (definition of it )

  2. Impcore expressions No statements means expression-oriented: (if e1 e2 e3) (while e1 e2) (set x e) (begin e1 ... en) (f e1 ... en) Each one has a value and may have side effects! Functions are primitive ( + - * / = < > print ) or defined with (define f ...) . The only type of data is “machine integer” (deliberate oversimplification)

  3. Names known in “environments” Ways to talk about meanings of names: • Scope rules • Name spaces • Environments (aka symbol tables) Impcore vars in 2 environments: globals, formals There are no local variables • Just like awk; if you need temps, use extra formal parameters • For homework, you’ll add local variables Functions live in their own environment (not shared with variables)

  4. Environmental abuse Abuse of separate name spaces: -> (val f 33) 33 -> (define f (x) (+ x x)) f -> (f f) 66

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend