-
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
Move hy-repr to core and rename eval
to hy-eval
#1550
Conversation
134d582
to
fe3d2df
Compare
Veto. I prefer the Python-compatible reprs as default, so you can see what's actually there instead of having to guess. I think changing the default repl output function to hy-reprs would only cause confusion. I don't mind changing |
Shame, because I was going to suggest doing it too.
I need to jig it around a bit more, and maybe as my time frees up this week I'll pull it out and do it a separate PR, but the importer rework has this change included. But its not just |
You can still review and approve this PR if you like it, and the PR can get merged with two approvals. What the veto means is just that the PR can't get merged under the two-week rule. For what it's worth, I fully expected Matthew to veto this because he disapproved the same thing a year ago, when I first wrote |
I like idea of renaming |
That sounds reasonable. Tuukka and I are for and Matthew is against. @vodik, are you for? Does anybody else (developers or users) have an opinion one way or the other? |
I'll reproduce examples from my previous objection below. This is never going to work right except for a narrow subset of data types. This is a niche use that shouldn't be the default. Going our own way makes us less compatible with the Python ecosystem. We cannot afford to do that. Hy's only chance to thrive is to embrace what Python offers. We can find other ways to fill these needs without breaking compatibility. Suppose you have some Python objects ( But wait, now we have to write a So what if we use generic placeholders instead? Now you've got Okay, maybe we can auto-wrap the repr with the placeholders. Now you get Even though this is a contrived example, it is very representative of the common case. It's very typical in Python for the repr to be a constructor call that defers to the reprs of its arguments. There are more Python libraries written in Python than in Hy, so almost all Python objects will have no hy-repr. @vodik consider my objections before deciding. @kirbyfan64 @olasd @algernon, you seem to have objected before to similar proposals. @hylang/core anyone else who wants to stop this, speak up. Do we know any other users? @ekaschalk? If we don't have a strong consensus, maybe we should leave this open for a while to hear from them? @paultag care to weigh in? Your opinion counts for a lot around here. We might also need an arbiter. |
This is a tough one. Let me think about it a bit. I can see both sides of this; on the one hand, having I half-heartedly reach for the bashism
) Let me work this over a bit |
To be clear, the point of most controversy here is using |
Right, I'm OK with having Anyway, the part I'm objecting to most is the Hy repl not printing valid Python reprs by default. If it's valid Python we could at least paste them back in the repl and |
@tuturto, it doesn't look like anybody else is weighing in, so the majority vote as it stands is aye. |
We should wait for @paultag. After considering this at length, I've decided that I am not fundamentally opposed to using s-expression output in the REPL. I think it would be nice. But I am vehemently opposed to making this half-baked implementation of it the default. This is nowhere near ready for core.
I think we could do better. But if we put this in core now, it may never happen. I would suggest that (if we want Hy reprs at all) we automatically convert Python reprs to Hy syntax.
This means that there's no Even if that's the default we should, of course, have an option to always output the Python reprs. There may be special formatting or comments and such that would get clobbered by the auto-translation. And to complete the loop, we ought to have a macro or something that allows us to write valid Python @hylang/core somebody stop this before it's too late. |
To be clear,
I don't think this is a good idea. It seems error-prone. But if I did it, would you approve this pull request? |
Oh it seems very error-prone, but that still seems a lot better than what you're proposing currently. Especially since we could probably detect most of them automatically and fall back to Python. In cases that don't, they can open an issue and we can try to improve the converter. We could maybe also give the user a hook to the repl output function to manually override the conversion if some case proves especially problematic.
Yes. To be clear, I would approve that pull request, not this one currently. (Pending other details, of course.) |
@brandonwillard I'm thinking of picking this back up again, but I recall that you wrote in a blog post about a major overhaul of |
This should be made obsolete by the bigger core changes I'd like to make in the future. |
The PyPy bug fix in the first commit has since gotten in by other means. |
hy-repr
is about a year old and it seems to work pretty well. With this PR,hy-repr
is used to print REPL output by default, and Hy gets a pair of functionshy-repr
andhy-eval
analogous to Python'srepr
andeval
, the latter of which is no longer shadowed by Hy.The change of default
repl-output-fun
will require a lot of documentation changes, of course, which I haven't yet done, but I will before this PR is merged.