Skip to content

no runtime error, when program doesn't follow golang specifications #1513

Answered by mvertes
KiranSatyaRaj asked this question in Q&A
Discussion options

You must be logged in to vote

The Go compiler rejects unused variables but yaegi accepts them. This is expected and necessary due to partial or incremental evaluations in the REPL or programatically: in a first eval the variable is created. It may be used only in a second eval (at the next prompt line). This is where a compiler and an interpreter differ fundamentally.

If we apply the compiler rule, it harms the interactivity, and forbids incremental eval. The cost of tolerating unused values is only extra memory consumption.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mvertes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants