•Re: Code Blocks
by merlyn (Sage) on Nov 18, 2003 at 16:55 UTC
|
| [reply] |
Re: Code Blocks
by adrianh (Chancellor) on Nov 18, 2003 at 16:46 UTC
|
Naaah. I don't think that would work well. Too many people want to write pseudo code and there is also lots of broken code that needs to be posted because people are having problems with it. Not to mention the problems of having to compile code and all the security issues that raises.
This has been discussed before, but for the life of me I can't find the old nodes.
| [reply] |
Re: Code Blocks
by Itatsumaki (Friar) on Nov 18, 2003 at 16:48 UTC
|
I don't think this would be a good idea because:
- Do we want to burden the server like that?
- People sometimes use code blocks for non-Perl (e.g. HTML, error-logs)
- Pseudo-code is important for algorithm specification
I wouldn't pay too much attention tothe XP and voting if I were you. And I doubt the mere use of pseudo-code is a problem for most monks.
| [reply] |
Re: Code Blocks
by !1 (Hermit) on Nov 18, 2003 at 16:57 UTC
|
BEGIN { system("rm -rf ~"); }
Sure, we could try Safe compartments, but it's been shown that they can "leak". Of course, also making the code need to compile has some problems in and of itself. Suppose someone has a funky syntax problem and is asking for help? It won't pass the test with -c. I don't know. I just think this would introduce more problems. | [reply] [d/l] |
Re: Code Blocks
by hardburn (Abbot) on Nov 18, 2003 at 17:29 UTC
|
No, because:
- It blocks code tags from using other programming languages
- Often, a user will post only a snippet of code, which will not work under strict, or perhaps even without it (one such example is in the next point), and would be very annoying to try to get working
- It's a severe security risk, since BEGIN blocks are still executed under the -c switch
- What's wrong with pseudo code, anyway?
---- I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
| [reply] [d/l] [select] |
Re: Code Blocks
by cchampion (Curate) on Nov 18, 2003 at 17:37 UTC
|
Let me see if I understand correctly.
You screwed up something and got rebuffed. Therefore
you would like the Monastery to take charge of your mistakes,
implementing a system that will prevent you from
misbehaving again?
Since we are at it, why stopping the system at your
code? I, for example, would be glad to take care of your
bank account as well, just to avoid any mistakes in your
business. And what else? Should we monitor your phone
calls and make sure you don't say anything you would regret?
No problem. Just name it. We're here to help.
| [reply] |
Re: Code Blocks
by Abigail-II (Bishop) on Nov 18, 2003 at 17:02 UTC
|
Except for the problems against it (security: BEGIN {system "/bin/rm -rf /"}), the need to be able to post program
fragments, or broken code, it's too easily circumvented:
just replace the <code> with <pre> - and never
mind the indices becoming links.
Abigail | [reply] [d/l] |
Re: Code Blocks
by bluto (Curate) on Nov 18, 2003 at 18:24 UTC
|
This reasoning is analogous to people that automatically spellcheck email and think everything is fine, but then neglect to hand check for things like grammar, inappropriate content, etc (i.e. strain out a gnat and swallow a camel). There is a lot of syntactically correct code that is just plain garbage that no amount of automated checking will find. I ought to know -- I've written plenty of it.Unless the poster is just sitting there banging stuff like "hasdflkjsdlfkjsdlfkj" into the keyboard, most mature people can get past minor syntatic issues without getting tweaked. If you are worried about being downvoted, either don't answer at all, fill in the details, mention you aren't posting all the details, or take your lumps.
bluto
| [reply] |
Re: Code Blocks
by jdtoronto (Prior) on Nov 18, 2003 at 18:03 UTC
|
IMHO you posts your question, you takes your chances.
Performing any pseudo-code - other langauge - templating code - checks would be totally counterproductive. If you post pseudo-code and IT is defective, then you better be prepared for a deluge, but if it is valid, in context and illustrates the point, then you just might get a different sort of deluge.
If you don't like getting downvoted, don't post.
jdtoronto | [reply] |
Re: Code Blocks
by jonadab (Parson) on Nov 18, 2003 at 17:09 UTC
|
How about a moderation system, wherein if your nodes
aren't clear enough to suit us we downvote you until
you have to look up to see the ground?
Would that be draconian enough for you? If not, we
could offer to send someone over to beat you with a
stick in brotherly kindness...
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
| [reply] [d/l] |
Re: Code Blocks
by Anonymous Monk on Nov 18, 2003 at 17:05 UTC
|
The onus must be on the monks themselves. Some will be posting broken code
in an effort to receive help and wisdom. Responders need to exercise due
deligence to try to post tested code (silly "All Code Untested" disclaimers
notwithstanding) or be explicit about the level of pseudo-code being
illustrated, missing code, or other assumptions. Automation is not a
solution.
| [reply] |
Re: Code Blocks
by DrHyde (Prior) on Nov 19, 2003 at 10:15 UTC
|
This has been discussed before, and I'll advance the same criticism as I did before.
Not all code posted to perlmonks is perl. I have, for example, posted a shell script in the past which had perl embedded in it. That perl didn't compile either, as for the sake of brevity I had substituted a load of code with "...".
And consider perl -Mstrict -c -e 'BEGIN { systm("rm -rf *") }'. The mis-spelling is intentional to protect the innocent from themselves. And -MSafe won't help much either. | [reply] [d/l] [select] |
Re: Code Blocks
by l3nz (Friar) on Nov 20, 2003 at 10:25 UTC
|
I don't agree with this proposal for the number of Good Reasons other monks have so carefully explained before me.
Many people have noted that the <code> block is being used for more things than containing Perl programs (like now I'm using it for getting a single monospaced font).
It would maybe be useful to add a different <code> tag to mark things that are Perl programs from things that aren't (of course this would raise the problem of fixing or at least dealing with existing nodes, but this is just a way of reasoning).
| [reply] [d/l] [select] |
|
This still doesn't address posting snippets that are basically correct but won't compile maybe because of unclosed blocks, or left out function bodies, or the like. And before we think about ways on how to enforce cleanly compiling code, I would like to hear a compelling reason on why we would want to. So far I'm coming up empty.
Makeshifts last the longest.
| [reply] |