You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The transpiled code seems to be highly backend dependant. Attempting something like a basic python slice already breaks c++ code:
def say_hi():
print( 'hello world'[3:6])
==>
File "./rusthon.py", line 539, in build
pak = translate_to_cpp( pyjs, cached_json_files=cached_json ) ## pak contains: c_header and cpp_header
File "<string>", line 13898, in translate_to_cpp
File "<string>", line 1244, in visit
File "<string>", line 13547, in visit_Module
File "<string>", line 1244, in visit
File "<string>", line 6341, in visit_FunctionDef
File "<string>", line 12084, in _visit_function
File "<string>", line 12212, in generate_generic_branches
File "<string>", line 1244, in visit
File "<string>", line 13723, in visit_Print
File "<string>", line 1244, in visit
File "<string>", line 10764, in visit_Subscript
__main__.GenerateSlice: {'upper': '6', 'lower': '3', 'slice': <_ast.Slice object at 0x102deabd0>, 'step': None, 'value': 'std::string("hello world")'}
Looks like to do some effective crossplatform program rusthon needs to reimplement a generic standard library which sometimes will map to the native standard library or implement some minimal code. Or maybe I have missed this support. Is it possible to write something like print(a.replace("h", "a")) and have it work on C++, Go, and Java?
This crosses needs with a PyPy project, where a lot of new languages written in RPython could benefit from such library of functionality with a known behaviour.
I would be interested in helping to create a python standard library for the JS backend. E.g. starting with math and random and then looking further to what needs to be done.
Would it make sense to create a repo under the rusthon umbrella for this purpose?
Activity
jcrubino commentedon Aug 17, 2015
This should be a priority and the standard tests can be built from this.
Where to start, Math, IO, Filesystem, OS?
techtonik commentedon Aug 18, 2015
This crosses needs with a PyPy project, where a lot of new languages written in RPython could benefit from such library of functionality with a known behaviour.
jcrubino commentedon Aug 18, 2015
Great observation
On Tue, Aug 18, 2015 at 5:23 AM, anatoly techtonik <notifications@github.com
wolfv commentedon Nov 15, 2015
I would be interested in helping to create a python standard library for the JS backend. E.g. starting with
mathandrandomand then looking further to what needs to be done.Would it make sense to create a repo under the rusthon umbrella for this purpose?
techtonik commentedon Nov 17, 2015
Any cross-language / cross-platform library should start with some kind of language-independent tests of behavior.