Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Here is an outline of how to make Win32::API much easier to use. It results in code like:

use Win32::API qw( CreateIoCompletionPort N kernel32 N N N N ); use Win32::API qw( ... ); # ... my $hIOCP= CreateIoCompletionPort( $hSocket, 0, 0, 0 ); # ...

which is much nicer than how I've used Win32::API. Of course, support for more DWIM argument types is also in order, but I think I've seen such work underway elsewhere. (In fact, I'd probably allow for a code ref as an argument specification...)

Here is how simple this improvement is to implement:

sub Win32::API::import { my( $class, $sub, $ret, $lib, @args )= @_; my( $pkg )= (caller 1)[3]; my $obj = $class->new( $lib, $sub, [@args], $ret ) or croak( "Can't find $sub in $lib" ); no strict 'refs'; *{"$pkg::$sub"} = sub { $obj->Call( @_ ); }; }

Does this type of simplification come from thinking like "the users", or am I just strange? Does this seem like a huge improvement to others? Anyone else felt "from the beginning" that Win32::API should be creating code refs, like that was the "natural" interface to provide?

I often suspect that many code authors don't put much stress on the point of view of the users of their code. But I find that my view of the world (in so many respects) looks quite skewed to most people...

I'm sorry that this is such a skimpy node. I'm tied up with my day job but wanted to throw this idea out anyway...

- tye        

In reply to How to make Win32::API easy to use by tye

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (4)
    As of 2020-09-25 22:06 GMT
    Find Nodes?
      Voting Booth?
      If at first I donít succeed, I Ö

      Results (141 votes). Check out past polls.