10 ms·
it's obvious that computer scientists have COMPLETELY dropped the ball by not figuring out a way for anyone to write "it", "that", "which" and so on and have th
by logicallee 11y ago
it's obvious that computer scientists have COMPLETELY dropped the ball by not figuring out a way for anyone to write "it", "that", "which" and so on and have the IDE and language disambiguate it into what you were JUST talking about. This is stuff that my great-grandparents should have been suggesting some time after Ada Lovelace wrote about the analytical engine in 1842 or 1843. Not something I should be writing about in 2016. Yeah, okay, before always-on Internet it might make sense to have a small, unambiguous, self-contained grammar. The same is not true in 2016.
Here's how you calculate the absolute value of an integer:
-> "if it's non-negative, return it; if it's negative return its opposite".
Here's how you calculate the absolute value of an integer if you're using any programming language written in 60 years:
-> "if (argument <= 0) return argument; else return argument * -1." (or some variation)
There is literally no way to refer to "it" instead of "argument" except by changing "argument" to read "a" (or "i" or "x" or "$_" or...)
My point is that it's literally impossible to write "if (it > =0) return it; else return (it * -1)" if you've just mentioned "it" and you are there to check and correct the IDE if it's wrong. (Oh, wait, I should write "to correct the IDE if the IDE is wrong.")
I bet 90% of human languages have a way to refer to something you've JUST mentioned without repeating a word for it. (Words like it, that, etc.) I bet 0% of computer languages let you write "it" for the last thing you just referred to, even if there is literally 1 choice in the whole function, as in my absolute value example.
Ridiculous!
- ArkyBeagle 11y ago"Computer scientists" don't have an opinion much about a particular IDE; if you want that functionality in an IDE, it might be a shorter path to cause it to exist in the first place. I bet it's harder than you think. Also, IDEs are better than they used to be - I stopped using them because they caused problems in the late 20th Century. There was a proliferation of them until Eclipse got good enough to not cause problems. Eclipse still had less text editing power than some just-plain-old-editors from the 1980s. So I only use an IDE if it's the only logical choice for a development system. It usually isn't. If, as in one shop at which I worked, you constantly write, say EMACS macros and use them a lot, you will evolutionary drift away and it will make your team more and more ... linguistically isolated, which has costs in onboarding and this sort of mild narcissism about your setup. I think that dependence on an IDE is mostly a weakness, not a strength.
- logicallee 11y agoThat is fair. I don't have a specific suggestion on how to implement it, which layer (language, IDE, some connected service) or where to do it. I just know that current coding practice must be wrong.
- ArkyBeagle 11y agoIf that's the worst thing you see, please consider being grateful :) It could always be worse.
- bryanlarsen 11y agoPerl's $_ probably comes closest to what you're asking for.
- dragonwriter 11y agoISTR several environments that have a direct reference to the result of the previous computation, including at least one that uses "it" to refer to that result. OTOH, I don't remember which one does that, and its a pretty-much completely search-proof topic.
- bjterry 11y agoAppleScript has an it keyword[0] that refers to the current application receiving commands. It's also made to resemble natural language in many other ways. From experience, this did not improve it's usability. It is often referred to as a read-only programming language because of that. Wolfram includes the % keyword for the last result generated, IPython has something similar within their notebooks, R has the .Last.value keyword, Matlab has ans, and many other languages often used from a REPL probably have similar constructs. 0: https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW4 https://developer.apple.com/library/mac/documentation/AppleS...
- nkurz 11y agoI realize it's not quite your point, but if you don't like repeating yourself, macros and "statement expressions" make it simple to extend languages to capture "it" to a tmp variable and then reuse it: #include <stdlib.h> #include <stdio.h> #define dry(x, test, if_true, if_false) ({ \ typeof(x) _x = (x); \ (_x test) ? if_true(_x) : if_false(_x); \ }) #define abs(x) dry(x, < 0, -, ) int main(int argc, char **argv) { if (argc == 1) printf("usage: %s num [num]...", argv[0]); for (int i = 1; i < argc; i++) { char *string = argv[i]; int num = atoi(string); printf("string '%s', num %d, abs %d\n", string, num, abs(num)); } return 0; } $ gcc -std=gnu99 -Wall -Wextra -O3 -g dry.c -o dry $ dry 2 1 0 -1 -2 string '2', num 2, abs 2 string '1', num 1, abs 1 string '0', num 0, abs 0 string '-1', num -1, abs 1 string '-2', num -2, abs 2