-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Make and
& or
aliases for &&
and ||
.
#19788
Conversation
With this changes it seem to be good for adding tests now: ismaelvc@toybox:~/vizen-juila$ ./julia
_
_ _ _(_)_ | By greedy hackers for greedy hackers.
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _' | |
| | |_| | | | (_| | | Version 0.6.0-dev.1801 (2016-12-31 01:28 UTC)
_/ |\__'_|_|_|\__'_| | Commit 90df437 (0 days old master)
|__/ | x86_64-linux-gnu
julia> true and :foo
:foo
julia> :(a and b)
:(a && b) |
and
& or
aliases for &&
and ||
or replace them.and
& or
aliases for &&
and ||
or replace them.
Does this keep the short-circuiting behaviour of Also I am against removing/deprecating |
Yes, it parses |
@vchuravy yes, as it is right now this PR implements |
and
& or
aliases for &&
and ||
or replace them.and
& or
aliases for &&
and ||
.
Could someone please cancel the previous CI tests, please? Thanks in advance! |
If we do this it should be one or the other, not both; synonyms in the language (excluding ASCII/Unicode synonyms) are just too confusing. But the plan would have to be to deprecate (Personally, I don't much care one way or the other how we spell it, but given how marginal the benefit of a rename seems — new users quickly get used to the spelling, and there's no way to please everyone anyway — I'd be happier leaving things as-is.) |
Build failure on Mac seems unrelated. |
@stevengj why can't Compat handle this right now? |
|
@Ismael-VC, because |
We could have a string macro for that; |
I vote -1 here. I don't think there is much benefit. It's generally good to avoid stealing words. The tradeoff when using punctuation is that it looks highly visually distinct, but can also be unclear. In |
@TotalVerb, wouldn't the string macro have to implement basically the whole 0.6 parser in order to work with arbitrary expressions? |
Good point. Then probably a deprecation at this stage is not practical. |
(@Ismael-VC, regardless of whether this is accepted, thanks for putting in the effort to make a PR. It's always easier to make a decision on things when there is actual code available to look at.) |
Nice job. For me " |
Tendency is to prefer the familiar -- it creates a comfort zone. And departure from habit is often perceived as irritation. Therefore it is difficult to be impartial on account of our conditioned experience. So may we all be super-conscious of this phenomenon!! I think JB's argument that In fact on account of highlighting, the argument now swings the other way: (It has been pointed out to me that not everyone uses syntax highlighting, however there is a clear trend towards it and one should act with an eye to the future).
Conversely, using |
Shouldn't we be looking long-term to replace Some of these logical symbols are obscure to computer programmers, but this is a direct result of keyboard layouts from many years ago. Maybe Julia can play a role in rectifying the situation? Maybe in 20 years all languages will be using standardised logic symbols and will look back upon all of this QWERTY nonsense the way we look at punchcards today... |
See #17472 and related discussion. |
@p-i- Yes people have biases, but notation is largely a matter of convention anyway. It's hard to argue that one symbol is objectively better than another. I don't think |
But we use words in other context without complaining about them: |
Yes, that's fair; a general objection to words as syntax is not the key argument here. My impression is just that |
@p-i- I think this is a perfect example of how having an actual PR for a proposal really concentrates minds in a way that endless discussions do not. The fact that this change can now be obtained by simply pressing a merge button makes the discussion here much more important. |
I think @Ismael-VC should feel very proud of his work on this PR even if it doesn't get merged. It's impressive work and deserves respect, whether or not people agree on the design. |
Yes, but I feel this is still missing the point that "Copying C syntax" isn't what it once was. Globally, a pretty strong consensus has emerged against certain aspects of C syntax, for example using |
I think the sentiment many have expressed in this thread stems from one of the hallmarks of Julia that attracted so many people to it. Quoting from the the original blog post:
I don't think I need to emphasize the parts that reflect the spirit of this proposal. As @tknopp said above, "we currently have the chance to make changes that will never be made after [1.0]." It seems to me that this syntax change certainly fits the both overall style of Julia code, and the principles of code clarity and approachability. |
|
@JeffBezanson: Then please close this to indicate that this is not going to happen. Sometimes better to draw a clear decision under the discussion of this and #5238. |
It's worth questioning how And in that case, I would prefer [WORD] [SYMBOL] [WORD]. But the reality is that nowadays syntax highlighting is generally available, which makes the operator stand out as a keyword. Maybe if we merge @KristofferC 's color-prompt... :) Having grown up with C's It's difficult to know which arguments for and against are ultimately motivated by a defensive post-rationalisation of something that has become instinctual. Well, Julia is a fantastic technology regardless of surface syntax scuffles, and I am in awe of the piercing minds that continue to crystallise structure. I hope that I have the sharpness, dedication and time to contribute in the future and @Ismael-VC 's work in putting this together has been inspiring (especially watching @TotalVerb mentor him through the process on Gitter). Watching this community work together is an effective antidote to something I cannot quite put my finger on. |
I want to second this statement. I still do most of my work programming in Python, and even though I really miss much of the performance and power of Julia, part of the reason I haven't pushed Julia more is that I don't find it quite as natural, so I find it difficult to push others to switch. The I'll be okay if this PR doesn't get in, of course, but I agree with the general arguments and goals of this PR and its proponents. |
I have used a lot Python and don't miss I do write some embedded C and C++ for data analysis as well, maybe my prefence would be different if I didn't. |
There is perhaps a reason to support One thing I'd rather not have is 2 ways to do it -- then the whole community has to learn both ways. I definitely miss |
(@clarkevans, Julia does use |
It seems a bit half handed to change
instead of
Credit to https://discourse.julialang.org/t/proposal-then-else-syntax-to-replace-short-circuiting/1323/46 |
@bramtayl, I think part of the point here is to better distinguish between boolean and bitwise operations. (Ignoring the fact that this probably doesn't have enough support to be merged… ) Cheers! |
I support this change. I find the word-notation easier to read at a glance and more intuitive to new programmers. It is also easier to type, involving no far stretching on a QWERTY layout. As has been mentioned, C has both notations via iso646 and ISO C++ has both built into the language. I have yet to meet anyone confused or burdened by having both choices. Even novice C++ coders I train pick it up easily, usually preferring Adding |
@holocronweaver, |
Yeah, seems like we're not going to do this. |
Though I'll reiterate that you did great work here, @Ismael-VC, and you should be proud of it even though it didn't make it in. |
Yes, thank you @Ismael-VC – sorry it came to naught but not for nothing! |
I understand. I also learned a lot from this, and just wish I had more time to keep contributing. Thanks guys, I admire your work. Julia is amazing. |
@martinholters could we reopen this PR, I can change the title to Replace && and || with and and or and make them not aliases. |
@Ismael-VC If I understand the discussion at #5238, when Stefan said
he was talking about
This is also what @martinholters stood for, when he reopened that issue:
So the uncontroversial action at this point would be to implement the reservation (as is currently done e.g. for |
Yea, I'd prefer to have discussion centralized at #5238 and in case a decision is reached that we want something that is sufficiently close to what this PR implements, then we can reopen it. |
Yes, sorry for the noise, Martin and Stefan clarified this to me in #5238 shortly after I asked for reopening this PR. |
This PR implements #5238
:(a && b) == :(a and b)
or:(a && b) != :(a and b)
?:(a && b) == :(a and b)
istrue
Do we want to deprecate
&&
and||
or ?and
andor
as aliases for&&
and||
respectively.Special thanks to @TotalVerb for taking his mentorship! 👏