|
Beardless Woman posted:And this guy's code is actually in production. Gazpacho fucked around with this message at 09:51 on Apr 12, 2009 |
# ? Apr 12, 2009 09:28 |
|
|
# ? Apr 29, 2024 06:04 |
|
Gazpacho posted:So what if it is? The code you posted apparently works; it's the broken code you should worry about first. People shouldn't feel obligated to use every redundant feature of a language. The "not" operator is a redundant feature?
|
# ? Apr 12, 2009 13:37 |
|
Flobbster posted:The "not" operator is a redundant feature? No, but "unless" certainly is.
|
# ? Apr 12, 2009 16:51 |
|
ehnus posted:No, but "unless" certainly is. What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"? e: Come to think of it, isn't "if" redundant if you have goto? And "else" is sure overrated hey? I just jump right there. Surely we don't need for loops if we have while loops. Why have a break statement when you can just use a flag? When does "arbitrary" cross into "quite helpful" for you? Especially if it boils down to the same instructions in the end. pokeyman fucked around with this message at 19:03 on Apr 12, 2009 |
# ? Apr 12, 2009 18:54 |
|
pokeyman posted:What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"? If is a conditional jump, goto has no condition.
|
# ? Apr 12, 2009 19:36 |
|
pokeyman posted:e: Come to think of it, isn't "if" redundant if you have goto? How would you conditionally branch with goto?
|
# ? Apr 12, 2009 19:45 |
|
Ugg boots posted:How would you conditionally branch with goto? Put function pointers in a two-element array and index the array with a boolean. Of course, that has nothing to do with goto. But I think there's some gcc feature that would let you do that with goto. Don't bytecode interpreters use that nowadays?
|
# ? Apr 12, 2009 19:46 |
|
shrughes posted:Put function pointers in a two-element array and index the array with a boolean. Pfft, function pointers are such a redundant feature
|
# ? Apr 12, 2009 19:48 |
|
Ugg boots posted:How would you conditionally branch with goto? Short-circuiting boolean operators.
|
# ? Apr 12, 2009 19:52 |
|
ShoulderDaemon posted:Short-circuiting boolean operators. Does that really work? http://codepad.org/iKriru3l Edit: Oh, but obviously not really with goto... Durr
|
# ? Apr 12, 2009 19:58 |
|
Every operation on a computer except for "Subtract and Branch if Less Than or Equal to Zero" is redundant, so it seems arbitrary beyond that to say "well this operation isn't redundant but this one is".
|
# ? Apr 12, 2009 19:59 |
|
Flobbster posted:Every operation on a computer except for "Subtract and Branch if Less Than or Equal to Zero" is redundant, so it seems arbitrary beyond that to say "well this operation isn't redundant but this one is". That operation is redundant if your computer is omniscient
|
# ? Apr 12, 2009 20:21 |
|
I don't see the point of arguing whether Perl has redundant features. Larry Wall admits it and is proud of it. Once upon a time in the 1990s, I wrote a fair amount of Perl code where I tried to be as concise as the language allowed, and a guy who had to maintain it later told me "WTF?" I don't write Perl like that anymore. Gazpacho fucked around with this message at 20:26 on Apr 12, 2009 |
# ? Apr 12, 2009 20:24 |
|
Gazpacho posted:I don't see the point of arguing whether Perl has redundant features. Larry Wall admits it and is proud of it. Wasn't arguing about Perl redundancy, more that being pedantic about redundancy in coding leaves you with a tiny set of nonredundant operations and most likely unreadable code. But I'm done. Regarding conditional goto: I meant to say branch, sorry. Branch/if and goto/break. Y'all got my point: higher-level constructs like if boil down to low-level constructs like branch, so they're redundant, but surely we find value in them, etc. etc. I don't think Beardless Woman found value in an empty code block, as he expected a not or an unless, so he posted it here. That's all.
|
# ? Apr 12, 2009 21:14 |
|
pokeyman posted:What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"? Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.
|
# ? Apr 12, 2009 21:19 |
|
ehnus posted:Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension. "If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct.
|
# ? Apr 12, 2009 22:05 |
|
ehnus posted:Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension. code:
Calling something "redundant" doesn't imply it's a worthless feature; we've covered this. Stop using that as a crutch, and just explain your opinion. pokeyman fucked around with this message at 23:10 on Apr 12, 2009 |
# ? Apr 12, 2009 23:07 |
|
pokeyman posted:
#3 trips me up and I'd have issue with it if I ran into it, but that's because I don't normally see/use them. It just isn't as clear to me as "if !A then B" to say "unless A do B". Heck, just typing that one and re-reading trips me up linguistically, it should be "do B unless A". edit: Although "do B unless A" looks a lot like "do B until A" which makes it even worse!
|
# ? Apr 12, 2009 23:33 |
|
I understand that everyone has their own sense of code aesthetics, I just wouldn't use it as the basis for calling something a coding horror when my solution is not really much better in production.
|
# ? Apr 12, 2009 23:40 |
|
Ryouga Inverse posted:"If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct. There are many common natural language constructs that have no business whatsoever belonging in a programming environment. In my case I find "unless" somewhat foreign (and less clear than if-not) because I'm largely steeped in C#/C++. If you can't figure out how to negate a boolean expression and require keywords like "unless" in your language then you probably aren't going to be a successful programmer. pokeyman posted:
It's simple - redundancy breeds inconsistency and inconsistency leads to incomprehensible code bases. Probably the worst example of this is Perl because there are so many ways to express the same functionality. Each programmer has their own idea of what they like, one may use "if (!condition) { blat }", another "blat if (!condition)", a third may use "unless (condition) { blat }", and a fourth "blat unless (condition)". When I'm working in an area of code that other people are working on and I come across something that isn't what I would think as idiomatic my mind is divorced from finding out what's going on in the code temporarily to figure out why the pattern was chosen. This is where coding standards come into play -- they help enforce consistent styles and practices so that people only really need to think about the problem at hand rather than why certain syntactic elements in the code were chosen. But if your coding standard dictates which of the conditional styles above are to be used then you've eliminated the need to have the alternate methods at all. If this is the case then redundancy has lead to these language extensions being worthless.
|
# ? Apr 13, 2009 00:18 |
|
Flobbster posted:"Subtract and Branch if Less Than or Equal to Zero" Is this actually enough for a computer to be Turing complete?
|
# ? Apr 13, 2009 00:40 |
|
ymgve posted:Is this actually enough for a computer to be Turing complete? Yes.
|
# ? Apr 13, 2009 00:44 |
|
Gazpacho posted:I understand that everyone has their own sense of code aesthetics, I just wouldn't use it as the basis for calling something a coding horror when my solution is not really much better in production. The horror is not the original programmer's failure to use negation, so much as the comment suggesting that the original programmer is unaware that negation is even possible.
|
# ? Apr 13, 2009 02:28 |
|
ymgve posted:Is this actually enough for a computer to be Turing complete? Note that you do need either memory cells to be unbounded or an unbounded number of cells. Models with bounded memory are never Turing-equivalent.
|
# ? Apr 13, 2009 02:42 |
|
rjmccall posted:Note that you do need either memory cells to be unbounded or an unbounded number of cells. Models with bounded memory are never Turing-equivalent. You need the cells themselves to be unbounded, since there's no way to refer to an unbounded number of cells with a value of bounded range. For what it's worth, even C isn't Turing complete unless you let "char" be an unbounded value (i.e. any natural or integer, rather than -128 to 127 or some such). This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension, then you can only reach a bounded number of memory addresses. Functional languages, like SML, OCaml, Haskell, and Lisp/Scheme, are generally Turing-complete without any extra weirdness. Their implementations usually aren't, of course.
|
# ? Apr 13, 2009 03:11 |
|
j4cbo posted:For what it's worth, even C isn't Turing complete... The C standard defines recursion, wouldn't that qualify it as being Turing complete (for values of "Turing complete" that incorporate resource limits) despite the data-width issues?
|
# ? Apr 13, 2009 03:56 |
|
j4cbo posted:This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension The first part of this does not imply the second part.
|
# ? Apr 13, 2009 04:20 |
|
Avenging Dentist posted:The first part of this does not imply the second part. The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant?
|
# ? Apr 13, 2009 04:25 |
|
This is all just theoretical bickering, though. To me it is "turing complete enough" if you can make a compiler for language xxx in C, and you can make a compiler for C in language xxx.
|
# ? Apr 13, 2009 04:27 |
|
j4cbo posted:The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant? "Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.) Incidentally, a conforming implementation of ISO C can have unbounded char values if it wants. The standard says nothing whatsoever about the size of a byte, and in fact goes out of its way to provide for systems where a byte is not 8 bits. Avenging Dentist fucked around with this message at 04:46 on Apr 13, 2009 |
# ? Apr 13, 2009 04:39 |
|
Avenging Dentist posted:"Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.) Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. That latter bit was my point - it's fine by the spec for char to be unbounded, and in fact is required for the language to be "actually" Turing-complete.
|
# ? Apr 13, 2009 04:57 |
|
j4cbo posted:Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. If you have infinite space (required for TC) you can define a decimal integer literal equal to aleph-0 (by way of writing a decimal expansion with aleph-0 digits). I mean, that's part of the basis of the proof that R is uncountable.
|
# ? Apr 13, 2009 05:04 |
|
j4cbo posted:That latter bit was my point - it's fine by the spec for char to be unbounded, and in fact is required for the language to be "actually" Turing-complete. Unless the spec also bounds stack space (which I don't think it does, given that it doesn't even mandate a stack), the boundedness of pointer size does not mean that C is not Turing-complete. You can "cheat" and use the unbounded stack to do whatever you want (e.g., implement the lambda calculus). floWenoL fucked around with this message at 05:10 on Apr 13, 2009 |
# ? Apr 13, 2009 05:07 |
|
Unless somebody points to a piece of standard that says otherwise, there's no reason a char can't be bounded between -128 and 127 while sizeof(int) == 4 where there is no bound on the possible value an int may contain. Edit: The reason was that you'd be limited to having 2^n distinct int values at any given time without being limited to having 2^n distinct ints. But if you're limited to having at most 2^n distinct ints, then that might violate some other rule of the language. shrughes fucked around with this message at 05:20 on Apr 13, 2009 |
# ? Apr 13, 2009 05:18 |
|
C is Turing-complete. Turing-completeness does not require that an unbounded amount of memory be simultaneously addressable; after all, that is not true of Turing machines themselves.j4cbo posted:You need the cells themselves to be unbounded, since there's no way to refer to an unbounded number of cells with a value of bounded range. With a single value, no, but that's not what I said. EDIT: of course that's inapropos if you're assuming a single-instruction machine without indirect addressing, which you might be, since I suppose that's what I was directly responding to. rjmccall fucked around with this message at 05:59 on Apr 13, 2009 |
# ? Apr 13, 2009 05:55 |
|
rjmccall posted:C is Turing-complete. Turing-completeness does not require that an unbounded amount of memory be simultaneously addressable; after all, that is not true of Turing machines themselves. I think it depends on the definition of Turing Complete you use. In the strictest sense, a Universal Turing machine requires an unbounded tape and any resource-limited machine cannot fit that definition. That said, most people use the looser definition where any language that would be Turing Complete when run on some theoretical unbounded machine is considered TC.
|
# ? Apr 13, 2009 15:24 |
|
But we're talking about languages, independent of any real-life machines. It's what the grammar can express that we're interested in, and not technicalities like sizeof(void*) or memory addressibility.
|
# ? Apr 13, 2009 15:28 |
|
TRex EaterofCars posted:I think it depends on the definition of Turing Complete you use. In the strictest sense, a Universal Turing machine requires an unbounded tape and any resource-limited machine cannot fit that definition. Unbounded, not infinite. If you formalize C as running on a theoretical machine with finite memory, then yes, your statement is correct; but if you formalize it as running on a machine with the full capabilities of, say, an IBM PC AT, then its space is theoretically unbounded, because if it runs out of space locally it can pause execution and say "Insert a new disk in drive A:".
|
# ? Apr 13, 2009 17:37 |
|
rjmccall posted:Unbounded, not infinite. If you formalize C as running on a theoretical machine with finite memory, then yes, your statement is correct; but if you formalize it as running on a machine with the full capabilities of, say, an IBM PC AT, then its space is theoretically unbounded, because if it runs out of space locally it can pause execution and say "Insert a new disk in drive A:". Yes but you'd run out of matter eventually. I feel dirty for how pedantic this is getting
|
# ? Apr 13, 2009 17:53 |
|
|
# ? Apr 29, 2024 06:04 |
|
Dijkstracula posted:But we're talking about languages, independent of any real-life machines. It's what the grammar can express that we're interested in, and not technicalities like sizeof(void*) or memory addressibility. Regardless, none of this helps me get porn to my computer faster and is thus meaningless.
|
# ? Apr 13, 2009 18:15 |