Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(Placeholder) Imagine!

by BrowserUk (Patriarch)
on Nov 30, 2016 at 03:24 UTC ( [id://1176894]=perlmeditation: print w/replies, xml ) Need Help??

This place excels in starting with a single, clearly defined, abstracted problem, and refining the set of proposed solutions down to a clear, concise, efficient solution. Many hands make light work!

Now, imagine if each of the Perl(5) opcodes was proffered here -- say: one per weekend -- on a Friday night - say: US West Coast time -- in the form of a hack-a-thon task for that weekend.

What might result from that exposure of a clearly defined task to the assembled (and usually quite bored on weekends), diverse populous?

If those more enlightened tolorant members of p5p were enthused to cast a critical eye over the proceedings -- to catch the less obvious pitfalls in the evolution of solutions -- then the results might be usefully fed back into the p5p process and result in benefits for all.

Thoughts on: Is the idea viable?

Thoughts on: Are any members of p5p willing to participate?

Caveats?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re: (Placeholder) Imagine!
by marto (Cardinal) on Nov 30, 2016 at 09:24 UTC

    I think this idea has merit. Have you reached out to the p5p mailing list regarding participation?

    Update: Since I rarely have any free time at weekends I do most of my perling/messing around during the week , during lunch/'compiling' time at work, perhaps letting each hack-a-thon run for one week would expand the audience for such a thing for those in a similar situation as myself.

Re: (Placeholder) Imagine!
by talexb (Chancellor) on Nov 30, 2016 at 14:42 UTC

    I admit that I have zero knowledge about this field of endeavor, but I do love a good brain teaser, and I have close to forty years of messing about with computers, so why not.

    However, I agree that having each post run for a week would be a better plan -- these days I look at Perlmonks during 'compile' time at work, or to give my self a short break. I'll only look at PM on the weekends if I have a lot of spare time.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: (Placeholder) Imagine!
by Tux (Canon) on Nov 30, 2016 at 15:55 UTC

    If you look at opcode.h, which is generated by opcode.pl from opcodes, you'll see that there are 397 basic perl OP's. Giving each a week? That's take looooooong. Or are you talking about other OP's?


    Enjoy, Have FUN! H.Merijn
      there are 397 basic perl OP's. Giving each a week? That's take looooooong.

      I wasn't suggesting we do them all. If there was any interest from p5p, we could pick the most critical or convoluted ops to start.

      There is also no reason to restrict ourselves to one weekend or even one week. If a chosen op produces lots of interest and makes good progress, keep it going; otherwise if no interest, kick it to touch and pick another. Or perhaps post half a dozen and just let people hack on them until they've either reached some level that is suitable for feeding back to p5p and then replace it; or if no good progress is made, replace.

      I admit it was a half-baked idea as presented; but I wasn't going to waste too much time on it unless there was a reasonable level of interest; and not too much opposition.

      So far I'd sum up the interest as: Meh.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice.

        I think it's very interesting. I fear that this site, despite the surplus of brain power, is not ripe with the requisite skills—core Perl stuff, history, entanglements, backcompat, roadmap, and more that would make the threads heavier with questions than answers—and that without nearly total buy-in from p5p, it would be an exercise in self-flagellation.

        I didn't comment previously because as interesting as it is, I am not one of the few who could help or push it forward.

Re: (Placeholder) Imagine!
by RichardK (Parson) on Nov 30, 2016 at 21:28 UTC

    I'm just not up to speed here, what's the issue with opcodes? what problem(s) are you trying to solve?

    But, why not throw one problem up here and test market the concept? ;)

      what's the issue with opcodes? what problem(s) are you trying to solve?

      It's not really about "solving a problem"; more, 'providing some entertainment with the possible side effect of producing something useful'; and, perhaps, widening the pool of people with internals skills.

      The perl opcodes are very clearly defined set of essentially stand-alone functions with a gazzilion existing tests. If their textual descriptions aren't yet readily available, they should be relatively easy to derive from the existing code.

      But, why not throw one problem up here and test market the concept? ;)

      I'm not sure this is the best way to go about this; but here goes. This is the latest relased version of substr:

      PP(pp_substr) { dSP; dTARGET; SV *sv; STRLEN curlen; STRLEN utf8_curlen; SV * pos_sv; IV pos1_iv; int pos1_is_uv; SV * len_sv; IV len_iv = 0; int len_is_uv = 0; I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; const bool rvalue = (GIMME_V != G_VOID); const char *tmps; SV *repl_sv = NULL; const char *repl = NULL; STRLEN repl_len; int num_args = PL_op->op_private & 7; bool repl_need_utf8_upgrade = FALSE; if (num_args > 2) { if (num_args > 3) { if(!(repl_sv = POPs)) num_args--; } if ((len_sv = POPs)) { len_iv = SvIV(len_sv); len_is_uv = len_iv ? SvIOK_UV(len_sv) : 1; } else num_args--; } pos_sv = POPs; pos1_iv = SvIV(pos_sv); pos1_is_uv = SvIOK_UV(pos_sv); sv = POPs; if (PL_op->op_private & OPpSUBSTR_REPL_FIRST) { assert(!repl_sv); repl_sv = POPs; } if (lvalue && !repl_sv) { SV * ret; ret = sv_2mortal(newSV_type(SVt_PVLV)); /* Not TARG RT#67838 */ sv_magic(ret, NULL, PERL_MAGIC_substr, NULL, 0); LvTYPE(ret) = 'x'; LvTARG(ret) = SvREFCNT_inc_simple(sv); LvTARGOFF(ret) = pos1_is_uv || pos1_iv >= 0 ? (STRLEN)(UV)pos1_iv : (LvFLAGS(ret) |= 1, (STRLEN)(UV)-pos1_iv); LvTARGLEN(ret) = len_is_uv || len_iv > 0 ? (STRLEN)(UV)len_iv : (LvFLAGS(ret) |= 2, (STRLEN)(UV)-len_iv); PUSHs(ret); /* avoid SvSETMAGIC here */ RETURN; } if (repl_sv) { repl = SvPV_const(repl_sv, repl_len); SvGETMAGIC(sv); if (SvROK(sv)) Perl_ck_warner(aTHX_ packWARN(WARN_SUBSTR), "Attempt to use reference as lvalue in substr" ); tmps = SvPV_force_nomg(sv, curlen); if (DO_UTF8(repl_sv) && repl_len) { if (!DO_UTF8(sv)) { sv_utf8_upgrade_nomg(sv); curlen = SvCUR(sv); } } else if (DO_UTF8(sv)) repl_need_utf8_upgrade = TRUE; } else tmps = SvPV_const(sv, curlen); if (DO_UTF8(sv)) { utf8_curlen = sv_or_pv_len_utf8(sv, tmps, curlen); if (utf8_curlen == curlen) utf8_curlen = 0; else curlen = utf8_curlen; } else utf8_curlen = 0; { STRLEN pos, len, byte_len, byte_pos; if (!translate_substr_offsets( curlen, pos1_iv, pos1_is_uv, len_iv, len_is_uv, &pos, &len )) goto bound_fail; byte_len = len; byte_pos = utf8_curlen ? sv_or_pv_pos_u2b(sv, tmps, pos, &byte_len) : pos; tmps += byte_pos; if (rvalue) { SvTAINTED_off(TARG); /* decontaminate */ SvUTF8_off(TARG); /* decontaminate */ sv_setpvn(TARG, tmps, byte_len); #ifdef USE_LOCALE_COLLATE sv_unmagic(TARG, PERL_MAGIC_collxfrm); #endif if (utf8_curlen) SvUTF8_on(TARG); } if (repl) { SV* repl_sv_copy = NULL; if (repl_need_utf8_upgrade) { repl_sv_copy = newSVsv(repl_sv); sv_utf8_upgrade(repl_sv_copy); repl = SvPV_const(repl_sv_copy, repl_len); } if (!SvOK(sv)) SvPVCLEAR(sv); sv_insert_flags(sv, byte_pos, byte_len, repl, repl_len, 0); SvREFCNT_dec(repl_sv_copy); } } if (PL_op->op_private & OPpSUBSTR_REPL_FIRST) SP++; else if (rvalue) { SvSETMAGIC(TARG); PUSHs(TARG); } RETURN; bound_fail: if (repl) Perl_croak(aTHX_ "substr outside of string"); Perl_ck_warner(aTHX_ packWARN(WARN_SUBSTR), "substr outside of str +ing"); RETPUSHUNDEF; }

      Can it be improved?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Can it be improved?
        Possibly. Possibly not. But that one function does quite nicely demonstrate why perl internals are complex and hard to work with. That "clearly defined" op has to cope with (from a quick perusal of the src):

        • both byte- or utf8-encoded strings - and having to convert between byte and char offsets - with a caching scheme for sometimes O(1) performance on long utf8 strings;
        • delayed lvalue assignment, with sometimes the lvalueness only known at runtime depending on how a :lvalue sub has been called;
        • being called in void, scalar or list context;
        • handling a variable number of args;
        • integer-valued args being either signed or unsigned (both are supported);
        • get and set magic;
        • being passed a reference rather than a string;
        • issuing appropriate warnings;
        • tainting;
        • locales;

        Putting all that together makes it really easy to break things, even with an extensive test suite.

        Dave.

Re: (Placeholder) Imagine!
by davies (Prior) on Dec 01, 2016 at 11:43 UTC

    I like the idea, but can't see myself being able to contribute much. I don't speak C & it looks from the substr code you have posted as though C will be essential. The reason I don't speak C is that I've never had a reason to want to learn it. This might provide such a reason, but I find it hard to imagine that this would be an appropriate project for a total beginner. I'm always interested in algorithmic puzzles, so if anything were flagged as "no C required" or something conveying the same message, I'd probably try to get involved.

    Regards,

    John Davies

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1176894]
Approved by atcroft
Front-paged by beech
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found