Mancy
Mancy copied to clipboard
Redclare const / class
Hi Prince,
awesome REPL! Thanks for the job. I wonder if it is possible to implement a feature so that we can redclare const variables or classes. Right now this fails:
class F {
constructor(A) {
this.a = A;
}
}
class F {
constructor(a) {
this.a = a*a;
}
}
TypeError: Identifier 'F' has already been declared
as well as:
const g = x /0 // <- ERROR
ReferenceError: x is not defined
const g = x => x /0 // <- oh, lets fix it
TypeError: Identifier 'g' has already been declared
Which is kinda annoying if you just want to play around with some data types.
The fix in the later example is to just say g = x => x/0
without let/const, but that is a bit weird..
For the class example. I don't know a fix...
Would be go cool if this can be solved somehow or maybe theres a workaround?
Greetings Markus
@MarkusPfundstein const
and class
are not really working well within REPL context.
Worst case solution is to provide a way to clear the context or a way to traverse the context backwards.
Or an icon in each execution output which will reset the context to that checkpoint.