Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[language/nim] confusing comment about immutable at the very start #4981

Open
ldemailly opened this issue Jun 22, 2024 · 1 comment
Open

Comments

@ldemailly
Copy link

ldemailly commented Jun 22, 2024

https://learnxinyminutes.com/docs/nim/

var                     # Declare (and assign) variables,
  letter: char = 'n'    # with or without type annotations
let            # Use let to declare and bind variables *once*.
  legs = 400   # legs is immutable.
const            # Constants are computed at compile time. This provides
  debug = true   # performance and is useful in compile time expressions.

it's very unclear to me as a complete ignorant about the language (but not ignorant about many others) what let is vs const?

to me immutable literal is no different than a constant, what am I missing? (and/or how is it different from var ?)

maybe a better example would be

let
  legs = someFunction()
const
  clegs = 42

?

@vendethiel
Copy link
Collaborator

It might be a better example, yes. The important part is only this:

Constants are computed at compile time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants