-
Notifications
You must be signed in to change notification settings - Fork 370
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
Remove redundant keywords #240
Comments
FWIW, We should clean that up.
In retrospect, not such a great idea, since we do allow |
I added |
|
I added 3 new pairs. I prefer |
+1 for the comment on nested loops with |
We also have This redundancy also bothers me. If there actually is a meaningful difference in how things are compiled/optimized, ( In cases the above doesn't apply, I generally prefer the shorter names. |
@algernon Can we also have this one in the "Grand Language Cleanup" milestone? |
The "which one to use" is a funny can of worms. But yes, this belongs to the Grand Language Cleanup. Last time this came up, one idea was to have a namespace that sets up the aliases. So if someone prefers CL-ish names: |
sigh
Here's an idea for ya, |
Haha, I like that suggestion. Oh boy, the possibilities! Tie it in with hydiomatic, and funny warning messages.... mmm. That'd be going a bit too far, though. So perhaps |
Found some more. I'll admit to using the easier-to-type aliases almost exclusively. But going by the heuristic, the clear winners are These have to be reserved words anyway for Python interop, e.g. even if we decided to use Common Lisp programmers unfamiliar with Clojure will be confused by |
OK, we've got most of #880 merged (except the last commit, The
The remaining duplicates (I know of) are:
I'd like to start with the first of the two remaining groups. In #880, @paultag said he's "OK with purging true false null and nil.", and my rationale is just above that. If another core member approves, I can try to put together a pull that purges these from Hy. If not, I'd rather not waste the time. It looks a little more difficult than the last fix. |
I'm -1 for removing
Now, I guess one of But |
One of So, for the second group, I suggest dropping |
I should just make a pull purging |
Yeah, |
This wasn't supposed to get closed yet, can we re-open? Did Github do it automatically again? |
Reopened; I agree that the way GitHub apparently closes an issue because a pull request mentioning it was merged (and then attributes the closing to whoever did the merge) is a very questionable "feature." |
The PR had a "close #240" string in its description, GitHub caught that, and thought you want to close it. You have to be careful around that thing, it listens to some keywords and ignores context, and then goes and destroys valid issues violently. Tsk, tsk. It can be a useful feature too, but one does have to pay attention. |
For |
Nothing has to be removed. Some convenience is worth a little extra complexity (though aliases aren't all that complex). |
Another option. We could also make >>> x = y = 1
>>> x
1
>>> y
1 Surprisingly, the above works, despite => (def x y 1)
x = y = 1
1
1
=> [x y]
[x, y]
[1, 1]
=> (setv x 2 y 3)
x = 2
y = 2
(x, y)
(2, 3) I'm not sure if I like this approach though. There may be better ways of getting the chained assignments. Maybe give => (setv x y := 1)
1 The presence of the Currently, by convention, On the other hand, globals are considered harmful. Maybe we shouldn't go out of our way to support them. Renaming Edit: or we could just remove |
What about making global x
x = 1 |
That would also align nicely with the current usage. |
That'll break when you're at module level :(
|
Also nested defns
|
I already said that:
And kind of rejected it:
|
Ah, I missed that. :) |
I thought Python actually allowed |
I thought too... |
|
I propose removing
The main problem with replacing all slices with islices, is that islice will always be a generator, but slices return another instance of the same collection type. Most of the time this isn't a problem. Python's libraries are very good about generally accepting iterables where you might have used a collection before. The main exception is strings, which really need to stay as strings. If you do run into a case like this, you can still use The case for dropping |
While we are there, I'd also suggest removing |
I use cons quite extensively in adderall. Without cons, both adderall and hydiomatic would be much harder to implement, and to work with. |
Does => (cons 0 [1 2 3])
from hy.core.language import cons
cons(0, [1, 2, 3])
[0, 1, 2, 3]
=> (type (cons 1 None))
from hy.core.language import cons
type(cons(1, None))
<class 'hy.models.expression.HyExpression'> Seems to mesh with lists just fine. => (cons -1 (range 4))
from hy.core.language import cons, range
cons((-1), range(4))
(-1 . range(0, 4))
=> (list (cons -1 (range 4)))
from hy.core.language import cons, range
list(cons((-1), range(4)))
[-1, 0, 1, 2, 3]
=> (type (cons -1 (range 4)))
from hy.core.language import cons, range
type(cons((-1), range(4)))
<class 'hy.models.cons.HyCons'> Maybe that's a cons cell. It seems to work with generators too. |
=> (cons 1 2)
(1L . 2L)
=> (type (cons 1 2))
<class 'hy.models.cons.HyCons'> This is what I use extensively in adderall & hydiomatic. This lets me do stuff like: (run* [q]
(prep
(== ?expr `(defn foo [params] (something) (something)))
(== ?expr `(~?fn ~?name ~?params . ~?body))
(== q ?body)))
;; => [((u'something') (u'something'))] Unifying on |
Okay, I'm convinced :). |
There are redundant keywords in the current implementation:
setf
/setv
/def
lambda
/fn
for
/foreach
(?)throw
/raise
catch
/except
do
/prgn
I believe we should avoid any ambiguity by removing duplication and settling on one of each. It's one of these things that we should worry about now, while we can afford to break the language.
The text was updated successfully, but these errors were encountered: