-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python-> hy converter #1721
Comments
https://github.com/woodrush/py2hy I don't think it's up to date though. See #876. |
Not an immediately usable answer, but I recently wrote something about Hy <-> Python AST (i.e. round-trip) compilation: Readable Strings and Relational Programming in Hy. |
@brandonwillard did you mean "equivalent and not exactly equal"? rather than:
|
And, very interesting article btw. Since this doesn't quite seem possible in practice currently, does anyone have advice for mixing Hy in to an existing Python team? Assuming that co-workers want to continue to use Python syntax and I want to use Hy syntax, what is the best way at this point in time to facilitate it? I was thinking that I could "own" any modules I write in Hy, be responsible for any feature or modification requests to them and if at some point in time others take a keen enough interest in it, do a one-way translation to Python and let them "takeover". Would that work? |
Yeah, looks like it. |
Short of getting your co-workers interested in Hy themselves, that's probably the way to do it, yeah. The code produced by |
From perspective of a hy freshman without lisp experience, it would be a lot better if there's an offical tool. |
Hi, I'm the author of py2hy. I'm sorry I wasn't able to work on py2hy for a long time. I'm now planning to update it for compatibility with the latest version. Congratulations on Hy reaching Version 1.0! Depending on how the py2hy project turns out, I am thinking of merging py2hy to an official command inside Hy's main repo. The first issue for this is relicensing, for license compatibility with Hy. I initially licensed py2hy with LGPL and am planning to relicense it to Expat to make sure we have license-compatible code. I'm fully OK with this, but since I'm currently having a pull request to py2hy that updates it to be Hy 0.18-compatible, I'm currently asking the author of the pull request if they're OK with relicensing as well. I also sent an email to the author. Even after merging the pull request, I probably still need to update things to make it Hy-1.0 compatible, which I plan to work on as well. Once I get the licensing issue resolved I am planning to start rewriting the code for compatibility. |
To be clear, we're still not at 1.0. Work you do to update your code for the current master will help you get to 1.0 compatibility, but 1.0 still doesn't exist yet.
If you can get your program to work without actually being part of Hy itself, then by all means continue with that. Hy is already big and complicated, so there's no benefit to trying to squeeze more stuff into the same repository. I'm open to moving your project into the hylang organization if you'd like to make it more official, though. LGPL is fine by me. I'm pro-copyleft, and I would've GPLed Hy if I'd been the one to start it. |
Sorry, I was looking at the repository's tag for the version. I checked pip and saw that we're at 0.20.0 now. I'll be working on the compatibility with that version.
Thanks for your support. I'll definitely be looking into that option once I finish it.
Thanks. Due to the current situation with py2hy I might stick with LGPL. |
|
I see. I'll make various versions for py2hy as well then, corresponding to the Hy versions. |
One workaround is to wrap the Python code into (pys "
def hello_world():
print('Hello, world!')
")
(hello-world) Outputs: I find this helpful when I want to use Python code snippets in Hy. |
You can also just import Python code from a file, and there are other options; see "Interoperability" in the manual. |
Hi,
Does there exist a Python -> hy converter? If not, how difficult would it be to create?
I’d imagine that the project would get a lot more adoption with this in place as it would allow those who will never be convinced of the goodness of s-exprs to interoperate more closely with those who have been convinced.
The text was updated successfully, but these errors were encountered: