do you guys ever have ideas for features in programming languages that you have never seen implemented but would like to?
i'm sure some of you have. i can't be the only one.
share them here.
i'll start with an idea i had a little while ago; i wouldn't be surprised if some language such as perl had already thought of it though.
have you ever been stuck writing long if statements along the lines of: if(c == x || c == y || c == z)?
sure, it might not look so bad in this case since it's rather short. but what if you could abbreviate it?
something like: if(c == ||(x,y,z)), or perhaps if(c == (x || y || z)), or even if((x,y,z)||==(a,b,c)), which would expand to if(x == a || y == b || z == c).
wouldn't that be a nice little time saver?
Name:
Anonymous2009-10-04 20:44
you could extend this using arrays.
i'll use perl notation in the example because it clearly differentiates arrays from scalars. if($c == ||(@array1)), expanding to if($c == $array1[0] || $c == $array1[1] || ... || $c == $array1[n])
>>1 have you ever been stuck writing long if statements along the lines of: if(c == x || c == y || c == z)?
Actually, I haven't. Maybe you need to put together a decision table and refactor your conditionals.
Name:
Anonymous2009-10-05 2:46
>>8
well how about: if(x == true || y == true || z == true )
then?
or if(x == true && y == true && z == true)
commonly seen in many languages with boolean type values
Name:
Anonymous2009-10-05 2:52
>>9
Not really. I might go two wide, but not often three.
The slow as fuck way in Perl: use Quantum::Superpositions;
if ($c == any($x, $y, $z))
...
Name:
Anonymous2009-10-05 22:22
>do you guys ever have ideas for features in programming languages that you have never seen implemented but would like to?
Nope I use Lisp so I just make them.
Name:
Anonymous2009-10-05 22:34
>>17 Lispers = the programming worlds equivalent to deluded Apple fanatics
nobody cares about your toy language.
Name:
Anonymous2009-10-05 22:36
>>18
Would a toy language be able to write as many parens in one line as you write in a whole C program? Now who has the fucking toy language?
Name:
Anonymous2009-10-05 22:38
>>19
yes. that's exactly the kind of thing toy languages are created for.
Name:
Anonymous2009-10-05 23:08
>>1 elem or zipWith (==) or all (==a) or whatever the hell you want
Name:
Anonymous2009-10-06 0:48
forget it, its NP-complete
Name:
Anonymous2009-10-06 3:14
>>18
Somebody's mad that their obsolete-before-it-was-designed language doesn't live up to Lisp's example.
Name:
Anonymous2009-10-06 3:35
>>1 have you ever been stuck writing long if statements along the lines of: if(c == x || c == y || c == z)?
Use switch for superior performance: switch(c)
{
case x:
case y:
case z:
/* whatever */
}
Name:
Anonymous2009-10-06 7:03
>>24
Use macros for superior readability!
switch (c) {
case x, y, z:
/* whatever */
}
Oh wait, you can't do that because C doesn't support meta-programming! lol!
>>27
I expect C to be C, a portable assembler where you can (mostly) predict the performance of your program.
There are high-level languages which support meta-programming(and of those that I can think of (Lisp and SEPPLES), both have implementation-dependent ways which support low-level stuff when needed), but that's their purpose, it's not C's purpose.
Name:
Anonymous2009-10-06 12:44
>>27
Here's a tip, boy: never show your hand like that. This is /prog/. Counter-metatrolls trolling metatrolls trolling trolls and FV trolling everyone. Don't ever forget it.!
>>1
You might be surprised, but there is a language that does that and then some more: IF SALARY > 9000 OR SUPERVISOR-SALARY OR = PREV-SALARY
I leave the conclusions as an exercise for the reader.
>>33
C's macros are barely useful. Retarded templates based on textual (!) substitution. If C macros could actually generate code, C would be much more usable.
Name:
Anonymous2009-10-06 15:10
I would like to see an interpreter that allows me to export my defined functions at the end of a REPL session (or whenever) instead of having to edit the file in my editor and then have to keep reloading it in the interpreter. Bpython comes close, in that it exports all the commands and comments out the replies, but I'd rather the functionality was built into the interpreter rather than having to run a script on the saved session to extract only the final function bindings. I'll probably add it to my own scheme interpreter if I ever stop being a lazy bastard.
Name:
Anonymous2009-10-06 15:23
>>39
Are we talking about Python here? Because any decent Lisp editor will let you send functions right from your file to your Lisp.
Name:
Anonymous2009-10-06 15:28
>>40
I was talking about Python there, but which Lisp editors are you referring to?
Since I, unlike some people, visit /b/ approximately one and a half times per year, and, unlike some people, do not feel insecure at the thought that some people might think otherwise, and, finally, since I barely registered this reference to a so-called «Meme», I had not felt a slightest desire to alter the number.
Name:
Anonymous2009-10-06 16:10
>>41
All of them, I'd think. Slime, the Lispworks IDE, ABLE... I obviously don't need to mess with any of them but Slime.
>>44
Hmm, M-x slime-edit-definition seems to be roughly what I'm after. Does it require me to stop and restart the interpreter? or can I immediately start working with the new definitions? >>45
DrScheme is what I've been using (or occasionally running and inferior scheme with quack-mode) and it's explicit stop-and-run is no better that having to use reload in python although it is more convenient.
Name:
Anonymous2009-10-06 23:37
>>46 DrScheme is what I've been using and it's explicit stop-and-run is no better that having to use reload in python although it is more convenient.
? You don't have to type in the definitions area. Just ctrl+d and the repl loop is yours to do with as you please, including save. Save interactions as...
>>47
I hadn't noticed that feature, but it just saves all the interactions(much like bpython or idle would for python) and misses the point of my original rant. Which is, "Why should I have to write a separate script to process my interactions, when my interpreter has all the bindings information built in?"
More likely you're looking for slime-compile-defun (C-c C-c). M-. — slime-edit-definition — is useful, but it's more of a cross-referencing tool. You just put the cursor on a top-level form and press C-c C-c, and your new code is compiled and ready to go. It's not exactly a REPL dump, but I'd rather type my code in a file to begin with so I can organize it.
>>50
It's not that I don't separate my code into files, but it's not unusual for me to just spend a lot of time just tweaking things and then having to copy+paste code from my REPL and I would rather my tools took care of this than having to keep interrupting my workflow. Thanks though, I'll need to investigate SLIME further.
Name:
Anonymous2009-10-07 21:14
>>51
Right, that's what I thought you wanted. Most tools, you can just C-c C-c a definition (or whatever key) and it's sent straight to the Lisp, no cut/paste bullshit. Use a file for a scratch area instead of the REPL, and you're good to go.
>>50-53
I write most of my code in a file, and send it to the REPL using the appropirate SLIME commands. I switch to the REPL when I want to test functionality of newly written code or write any throw-away code.
Name:
Anonymous2009-10-08 18:59
>>61
But that is how Haskells do it. Haskells are not a real programmer !!
The REPL is there for newcomers to learn the language. If you are programming in the REPL, you are a fucking idiot and should feel kind of bad about it :(
>>62
I can and do use whole project(just load up and compile the ASDF system) compilation when starting up my image. I compile individual definitions or run them as required, this is smarter and faster than just reloading and recompiling everything. >>64
Programming, no. Testing/experimenting throw-away code, yes.
There is no reason to write code at the REPL that you're going to throw away. Some people may prefer copying REPL transcripts to a file, but I find it too messy for my own tastes.
In most implementations, you interact with the live image through the REPL, even if you don't realize it. Even if all you do is a couple of COMPILE/LOAD/COMPILE-FILE (SLIME and/or ASDF will do it for you transparently). In the end it doesn't really matter, if you have a better way to interact with your image, you just do it.