|
You can have brackets close in separate code chunks?
|
# ? Apr 19, 2012 18:42 |
|
|
# ? May 14, 2024 14:30 |
|
How else would you do this?php:<? for ($i = 0; $i < 5; ++$i) { ?> welp <? } ?>
|
# ? Apr 19, 2012 18:50 |
|
php:<? WELP: ?> welp <? goto WELP; ?>
|
# ? Apr 19, 2012 19:43 |
|
Why does a modern programming language still have gotos!?
|
# ? Apr 19, 2012 20:00 |
|
Ensign Expendable posted:Why does a modern programming language still have gotos!?
|
# ? Apr 19, 2012 20:03 |
|
Ensign Expendable posted:Why does a modern programming language still have gotos!? Modern programming languages having gotos is not a horror. PHP having gotos probably is, and them explicitly adding them ~15 years after the language came about is probably a bigger one
|
# ? Apr 19, 2012 20:10 |
|
No Safe Word posted:Modern programming languages having gotos is not a horror.
|
# ? Apr 19, 2012 20:15 |
|
Ensign Expendable posted:Why does a modern programming language still have gotos!? Every so often explicit code jumps are useful, here's a fragment I recently used one in. While you can write this block in other ways, I like the flow better this way. code:
|
# ? Apr 19, 2012 20:16 |
|
php:<?php function h3($body) { ?> <h3><?= $body ?></h3> <?php } h3("One"); h3("Two"); ?> code:
|
# ? Apr 19, 2012 20:19 |
|
Suspicious Dish posted:<?= $body ?> What is this special "<?=" opener? I can't find any docs on that.
|
# ? Apr 19, 2012 20:24 |
|
baquerd posted:What is this special "<?=" opener? I can't find any docs on that. I believe that just does an echo.
|
# ? Apr 19, 2012 20:28 |
|
It's short for "<? echo ".
|
# ? Apr 19, 2012 20:29 |
|
No Safe Word posted:Modern programming languages having gotos is not a horror. I use gotos in PHP to abandon deep foreach loops because break N; is bullshit.
|
# ? Apr 19, 2012 20:41 |
|
trex eaterofcadrs: I find that when I have deeply nested loops which I might want to exit, it's better to break the loop nest out into a separate function and do an early return. I've actually spent years trying to find a situation where a labeled break is the cleanest way to solve a problem, and I've always come up with a different solution. The best defense of goto that I've seen is implementing state machines in procedural languages.
|
# ? Apr 19, 2012 20:48 |
|
Ensign Expendable posted:Why does a modern programming language still have gotos!? goto isn't automatically bad. Example: http://kerneltrap.org/node/553/2131
|
# ? Apr 19, 2012 20:53 |
|
Would anybody consider it to be a design horror whenever you hear somebody talk about "adding a layer," then seeing the layers being represented as a bunch of boxes with arrows pointing all over the place? Wouldn't you expect layers to, say, layer? If that is so odd, would you consider it to be a megahorror when somebody proposes a layer to poll on a database to find new operations to do?
|
# ? Apr 19, 2012 20:56 |
|
Internet Janitor posted:trex eaterofcadrs: I find that when I have deeply nested loops which I might want to exit, it's better to break the loop nest out into a separate function and do an early return. I have one case where I use goto; matched with a label, out: code:
|
# ? Apr 19, 2012 21:10 |
|
Internet Janitor posted:trex eaterofcadrs: I find that when I have deeply nested loops which I might want to exit, it's better to break the loop nest out into a separate function and do an early return. I haven't had to use a goto or labelled break in years, but I certainly feel more comfortable knowing they're available.
|
# ? Apr 19, 2012 21:12 |
|
Ensign Expendable posted:Why does a modern programming language still have gotos!? A reminder that Djikstra wrote that paper in 1968. Take a look at arithmetic ifs and imagine trying to get anything done in FORTRAN circa 1968.
|
# ? Apr 19, 2012 21:41 |
|
Suspicious Dish posted:I have one case where I use goto; matched with a label, out: Another nice feature is that execution falls through labels nicely, so you can do more complicated cleanup like this.
|
# ? Apr 19, 2012 22:06 |
|
In retrospect I have no problem with goto as long as it doesn't jump backwards through the code somehow. Now, in terms of nonlinear code execution, here's the real horror.
|
# ? Apr 19, 2012 22:08 |
|
Suspicious Dish posted:
Wait, this actually works? This just seems wrong to me for some reason.
|
# ? Apr 19, 2012 22:23 |
|
baquerd posted:Every so often explicit code jumps are useful, here's a fragment I recently used one in. While you can write this block in other ways, I like the flow better this way. I don't have a compiler at hand at the moment, so this is straight from the hip, but I think this could be written as code:
|
# ? Apr 19, 2012 22:23 |
|
NovemberMike posted:Wait, this actually works? This just seems wrong to me for some reason. If PHP had a slogan, that would be it.
|
# ? Apr 19, 2012 22:34 |
|
NovemberMike posted:Wait, this actually works? This just seems wrong to me for some reason.
|
# ? Apr 19, 2012 22:40 |
|
Plorkyeran posted:It's perfectly sensible if you think of PHP as a templating language rather than a general-purpose programming language. Actually switching between PHP and HTML when using PHP as a programming language is a horror, of course. Yeah, all php is doing is building an output buffer and writing it to some pipe/stream. Escaping is really "shorthand" for buffer concatenation.
|
# ? Apr 19, 2012 23:26 |
|
I'm pretty sure the ability to do things like that is the only reason most people put up with PHP at all. Edit: VB.NET can do similar things with XML Literals: code:
Zhentar fucked around with this message at 23:53 on Apr 19, 2012 |
# ? Apr 19, 2012 23:51 |
|
pigdog posted:I don't have a compiler at hand at the moment, so this is straight from the hip, but I think this could be written as Yeah you're right, I did what was going to happen behind the scenes needlessly there.
|
# ? Apr 19, 2012 23:55 |
|
hobbesmaster posted:A reminder that Djikstra wrote that paper in 1968. Take a look at arithmetic ifs and imagine trying to get anything done in FORTRAN circa 1968. Yeah, you have to remember that paper isn't so much against goto as it is advocating the use of language constructs like loops, blocks, else clauses, and switch statements, which weren't common at the time.
|
# ? Apr 20, 2012 00:10 |
|
Suspicious Dish posted:
The only coding horror is that he doesn't bother just using the short tags since he's already ruined it by having a "<?=" Why bother with "<?php" if you're already guaranteeing your script to fail when someone turns off short tag support. Edit: Ah apparently since 5.4 <?= is accessible regardless of whether short tags is on or off... Certainly not a coding (implementation?) horror. No siree bob. Strong Sauce fucked around with this message at 01:09 on Apr 20, 2012 |
# ? Apr 20, 2012 01:05 |
|
Vanadium posted:How else would you do this? like so php:<? for ($i = 0; $i < 5; ++$i): ?> welp <? endfor ?>
|
# ? Apr 20, 2012 01:16 |
|
tef posted:like so Probably the absolute best aspect of php.
|
# ? Apr 20, 2012 01:19 |
|
Plorkyeran posted:Actually switching between PHP and HTML when using PHP as a programming language is a horror, of course. I'm not a professional web dev by any means, but why is this such a horror? The function makes sense if you think about it differently: php:<?php function h3($body) { ?><h3><?= $body ?></h3><? } h3("One"); h3("Two"); ?> ?><h3><?= $body ?></h3><? expands to: echo "<h3>" . $body . "</h3>" It's godawfully ugly when it's spaced out like that of course. I just think of these kind of languages as having statement-level automatically-printing html literals.
|
# ? Apr 20, 2012 01:23 |
|
ASP.Net will let you do the same thing, so do the MVC partial views. It's just shorthand for wrapping the text between the code bits in a string then doing an output stream write of that string. Wait, it's PHP it probably does something much dumber than that...
|
# ? Apr 20, 2012 01:39 |
|
Contero posted:I'm not a professional web dev by any means, but why is this such a horror?
|
# ? Apr 20, 2012 01:52 |
|
Contero posted:I'm not a professional web dev by any means, but why is this such a horror?
|
# ? Apr 20, 2012 02:20 |
|
There's a "new" OpenSSL vulnerability in the parser for ASN.1, a good example of the hilarious overcomplication that design-by-committee causes. Some people are smart: djmdjm posted:FYI OpenSSH's sshd is not vulnerable, despite using OpenSSL. Back in 2002 and after a different ASN.1 bug, Markus Friedl observed that RSA verification used the OpenSSL's full ASN.1 parser to parse PKCS#1 RSA signatures despite them having an almost entirely fixed format under the parameters used in the SSH protocol. Some are cheeky as well: mdowd posted:I published that bug in our book (TAOSSA) in 2006. I just neglected to mention it was 0day.
|
# ? Apr 20, 2012 03:11 |
|
Plorkyeran posted:"Don't mix HTML generation and program logic" is pretty much the most basic rule for designing a web application that is not an unmaintainable mess. A straightforward conclusion based on this is that a feature which makes it easier to embed HTML should only be used when PHP is being used as a templating engine, not as a general-purpose programming language. If all you're saying is "separate business logic from presentation" then I'm completely on board with you. I think you've confused me by using "program logic" (is a loop not program logic?) and "general-purpose programming" to mean complicated or application specific logic: Plorkyeran posted:Actually switching between PHP and HTML when using PHP as a programming language is a horror, of course. If not as a programming language I'm not sure how you're supposed to use PHP. The way you worded it made it sound like you were advocating something like this: code:
|
# ? Apr 20, 2012 04:04 |
|
Gazpacho posted:If you consider COBOL dead maybe your "sense of the industry" isn't quite as good as you think. I spent the first part of my career as a COBOL programmer. Its not the language thats dead, but me who is dead, inside. Terrible terrible language. But yeah, theres still billions of lines of that godawful poo poo out there.
|
# ? Apr 20, 2012 05:00 |
|
|
# ? May 14, 2024 14:30 |
|
Zamujasa posted:
quote:} // end of is api command 'doeverything'
|
# ? Apr 20, 2012 05:02 |