Skip to content
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

Docs: Hy <-> Python interop fix #1061 #1218

Merged
merged 6 commits into from Feb 11, 2017
Merged

Docs: Hy <-> Python interop fix #1061 #1218

merged 6 commits into from Feb 11, 2017

Conversation

ghost
Copy link

@ghost ghost commented Feb 5, 2017

I separated the existing text in two sections, with some additional explanations and a link to Hy's import.

I separated the existing text in two sections, with some additional
explanations and a link to Hy's `import`.
@Kodiologist
Copy link
Member

You can also compile your module with hyc. Then you can import it directly (Hy still has to be installed)

This isn't always true. If you edit the example greetings module by renaming the parameter name to addressee, then the resulting greetings.pyc no longer requires Hy. Using name makes Hy add from hy.core.language import name at the top of the file because name happens to be the name of a builtin. (Is this a bug or an unavoidable limitation of Hy? It's not obvious to me.)

More generally, I think that fulfilling #1061 calls for adding discussion of lots of gory details. Your additions here don't suffice. @gilch filed that issue, so maybe he can chime in.

It looks like this is your first pull request. Please don't be scared away by how I've received it; we do need more contributors, to both the code and the documentation. Thanks for pitching in.

@ghost
Copy link
Author

ghost commented Feb 6, 2017

First PR indeed, not scared away 😬

More generally, I think that fulfilling #1061 calls for adding discussion of lots of gory details. Your additions here don't suffice.

In that case, maybe this should be completely moved away from the tutorial, which would still contain general interop instructions without the “gory details”.

What I have understood so far is that if anywhere in the code, the name of a Hy builtin is found, it is imported.
For example :

(def second 42)

triggers

from hy.core.language import second

@Kodiologist
Copy link
Member

In that case, maybe this should be completely moved away from the tutorial, which would still contain general interop instructions without the "gory details".

Yeah, that makes sense to me. We've generally agreed that the tutorial should be fairly short so it isn't too intimidating.

What I have understood so far is that if anywhere in the code, the name of a Hy builtin is found, it is imported.

I think that's how it works, yeah. I've never read the part of the codebase that does this.

Copy link
Member

@Kodiologist Kodiologist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. Thanks! You even nailed the dorky, humorous tone of the preexisting text.

I have a few requests:

  • The section on mangling is incomplete (e.g., there's no mention of ?), but a complete discussion of mangling should probably be in a different part of the documentation anyway, since mangling can surprise you if you aren't trying to do Python interop (e.g., hy -c '(setv *a* 1) (print (in "*a*" (globals)))' prints False). I'd suggest documenting mangling in a separate PR.
  • "Even if you do not use a Hy symbol, but just the same name": In the above example, name is still a Hy symbol. What's weird about it is that it will resolve to a local variable instead of the Hy builtin named name. So you could instead write "Even if you do not use a Hy builtin, but just another variable with the name of a Hy builtin".
  • You can remove the bit about keyword arguments, which looks like a non-sequitor. I think the only reason it was present originally was that Hy used to lack direct syntax for keyword arguments, so you'd have to use apply.
  • Write "See?" rather than "See ?". In English, we never put a space before a question mark or exclamation point.
  • Write "Suppose you have written…" rather than "You have written…".
  • On line 52, you have a stray trailing pair of colons.
  • The sequence : :: can be written as just ::. (You should read up on reStructuredText if you haven't already.)

@Kodiologist
Copy link
Member

Oh, and don't forget to add yourself to AUTHORS.

@Kodiologist
Copy link
Member

I'd suggest documenting mangling in a separate PR.

Although, you may not want to do this now since mangling may change soon (#1173, #1115), anyway.

@ghost
Copy link
Author

ghost commented Feb 10, 2017

Thank you for those words! (tssst, I wanted to put a space before my exclamation mark. It’s hard being French when writing in English)
I’ll make the corrections quickly.

I'd suggest documenting mangling in a separate PR.

Shouldn’t mangling still be mentioned in this section? Maybe a link would suffice.

@Kodiologist
Copy link
Member

Yeah, a link would make sense.

ealhad added 2 commits February 11, 2017 00:48
I kept the part about mangling, but added a warning about its incompleteness. I
think it can be useful for somebody who just wants to use a Python module in his
code. Maybe it can be removed when the actual documentation for mangling is
written.
I'll do my best to be worthy of it. Thanks for this awesome project!
@Kodiologist Kodiologist merged commit 83cdaf0 into hylang:master Feb 11, 2017
@ghost ghost deleted the hy-python-interop branch March 1, 2017 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant