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.