-
Notifications
You must be signed in to change notification settings - Fork 371
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
import syntax improvements #1612
Comments
If you drop the inner list like that, I think we should switch to |
We should also make |
Fortunately, that's easy now that |
Clojure's approach could perhaps be simplified further, like
Which would be like
So an expression sets the prefix for all of its children. But this potentially breaks the "preferably only one obvious way to do it" rule, since you can now use either a
Removing the
Maybe it's not worth the trouble. Clojure's way is closer to the Python compilation and it's not too hard to build macros on top of simpler special forms. |
Related #851. |
Removes an unnecessary level of indentation, and changes them from using lists to expressions. Closes hylang#1612
I just did the basic implementation for now.
It might not be worth it as Python doesn't typically tend to have deeply nested namespaces - its instead tends to being broad.
Not a bad idea, but I think I see two problems: Multiple dots are valid as a indicator to go up. Now I guess you can just toss in more parenthesis, but the question is how clearly indent level is that conveyed:
The other problem is I have no idea how you'd express this:
|
A good point. Even though I wished Clojure had something like this, it's probably not worth the trouble in Hy. |
|
;; Clojure-like
(import (os.path exists
isdir :as dir?
isfile :as file?)
sys :as systest
re) from os.path import exists, isdir as is_dir, isfile :as is_file
import sys as systest
import re The closest we could get to Python would be with two special forms, ;; Python-like
(from os.path :import exists isdir :as dir? isfile :as file?)
(import sys :as systest)
(import re) If we reverse the order, we don't need the (import exists isdir :as dir? isfile :as file? :from os.path) These have no internal brackets, but like Python, you'll need to repeat |
Removes an unnecessary level of indentation, and changes them from using lists to expressions. Closes hylang#1612
Removes an unnecessary level of indentation, and changes them from using lists to expressions. Closes hylang#1612
Removes an unnecessary level of indentation, and changes them from using lists to expressions. Closes hylang#1612
We've used to have three forms for importing:
We've currently dropped the second form, but that leaves a weird inconsistency:
The inner list is no longer necessary. We're now free to change the syntax to be less nested:
And this is close to how Clojure does it (though with expressions instead of lists):
The text was updated successfully, but these errors were encountered: