wheineman / nrpl

Nim REPL
MIT License
56 stars 9 forks source link

Redefinition of values #6

Open andreaferretti opened 9 years ago

andreaferretti commented 9 years ago

This fails

> let x = 25
- 
> let x = 12
- 
> echo x
nrpltmp.nim(3, 5) Error: redefinition of 'x'

In REPLs it is usually understood that newer definitions shadow the old ones.

Scala manages to do this by evaluating each expression in an inner scope. You may do the same by adding a new block for each expression to be evaluated

wheineman commented 9 years ago

Hmmm. I'll have to think about this. If it's in the same scope, it's intended that the second declaration replaces the first declaration within the REPL. However, nrpl is not a real REPL and merely a front end to the compiler, and it is a coding error in that context. I'll meditate on this one a bit.