-
Notifications
You must be signed in to change notification settings - Fork 10
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
->
no longer works with dot expression
#83
Comments
Note this used to work in older versions of Hy. It is possible that the recent changes to |
This looks like the correct behavior to me. |
@scauligi You were working on |
Hmm, I think they have a point here: (defmacro dot [#* syms] `(. ~@syms))
(-> x (dot real)) compiles to The problem is that the reader parses forms like However, I think it's reasonable to expect that while This would require a change to Hy's AST, to allow for a distinction somehow between In previous versions of Hy, I'm not quite sure what the right solution here is... Potentially we could add a flag or other metadata to the |
Ah geez, I don't want to change Hy's built-in syntax to make |
I guess there's always the ultimate flexibility obtainable by making |
Here is an example of where the old simpler interpretation of ; Find parent directory path of code where current stack frame is running.
(-> (inspect.currentframe) (inspect.getframeinfo) (. filename) (Path) (.resolve) (. parent) (str) ) The operator Here is the above line in a self-contained executable snippet. I’m overriding the latest (defmacro -> [head #* args]
(setv ret head)
(for [node args]
(setv ret (if (isinstance node hy.models.Expression)
`(~(get node 0) ~ret ~@(cut node 1 None))
`(~node ~ret))))
ret)
(import inspect)
(import pathlib [Path])
(-> (inspect.currentframe) (inspect.getframeinfo) (. filename) (print))
(-> (inspect.currentframe) (inspect.getframeinfo) (. filename) (Path) (.resolve) (. parent) (str) (print)) |
Hi, (import pandas :as pd)
(setv df (pd.DataFrame {"a" [1, 1, 2, 2, 3] "b" [4, 5, 6, 7, 8]}))
(print (get (. df shape) 0))
(print (->
(. df shape)
(get 0)
))
(print (-> df
(. shape)
(get 0)
)) The first two
I struggle to understand why the second works but not the third, not sure if this is a different situation from the previous ones in this thread? |
Yeah, looks the identical problem to me. |
The problem seems to be the I expanded the following expression as list, and found:
Since The original condition for
I added |
Sorry, I missed the case where the dotted expression is like |
That's correct. |
REPL session
Expected:
(-> x (. real))
should produce10
just like(. x real)
. It should not produce the errorNameError: name 'real' is not defined
.hyrule version: 0.5.0
Hy version: 0.28
The text was updated successfully, but these errors were encountered: