js-slang
js-slang copied to clipboard
String representation is not language dependent
When running Python, string representations are still following Source/JS notation:
Ideally, the REPL should show
lambda x: func(repeat(func, n - 1)(x))
as the program output instead.
Perhaps related to how stringify
in src/utils/stringify.ts
is implemented?
For the most part, JS and Python have overlapping representations where the complex stuff lies (arrays, dictionaries/objects and other nested data structures). So it would be good to reuse most of the existing code.
The main difference are the language constructs. For Python S1, the following need different representation:
- functions (as you pointed out)
- if-else
- ternary
- "blocks"
We need a rather big refactor of the stringify
function to make it language aware. CS2030S tells me that we shouldn't be adding if-else cases and instead should make a new subclass that contains these methods :).
Haha, fair enough. Need to see what's the canonical Python representation of estrees. I think we can work something out if we are willing to be a bit generous.
@martin-henz perhaps we could take a look at this issue together with the plans you mentioned to apply the visitor pattern to js-slang?