Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It's some Glib overloading. From muppet's explanation on the Perl/Gtk2 maillist:
> On 25/02/07, muppet <> wrote: >> Well, TIMTOWDI, of course. :-) But, yes, the ">=" operator, which +is >> overloaded for Glib::Flags bitsets to mean the same as "&", which i +s >> "are all of the flags listed on the right hand side set in the left >> hand side?" is how i would write it. > > I can see that &, >= and * should be the same for this example. > >> The Glib::Flags operators are explained in the "This Is Now That" >> section of the Glib manpage. > > But in the manpage, it implies (to me at least) that there is a > difference between &, >= and *. Is there difference? For a boolean test, no. & and >= are implemented differently, but * and & are the same. The names (and operators) are derived from set theory, but you can also use any knowledge of binary logic operations + from C. (Warning: potentially redundant but intended-to-be complete information follows.) contains this: package Glib::Flags; use overload 'bool' => \&bool, '+' => \&union, '|' => \&union, '-' => \&sub, '>=' => \&ge, '==' => \&eq, 'eq' => \&eq, # eq for is_deeply in Test::More '*' => \&intersect, '&' => \&intersect, '/' => \&xor, '^' => \&xor, '@{}' => \&as_arrayref, '""' => sub { "[ @{$_[0]} ]" }, fallback => 1; Those subs are implemented essentially like this: bool := NOT NOT a if any of the bits in a are set, the expression evaluates to TR +UE union := a OR b the result contains all of the bits set in a and b that is, the result is the union of the two sets. the | mnemonic is for the C (and Perl) bitwise OR operator. the + mnemonic is for union of two sets -- you're adding them together. sub := a AND NOT b the result contains all the bits set in a minus the bits that were also on in b. this is subtracting the set of b from the set of a. the - mnemonic is awesome, because "a & ~b" is bizarre looking. ge := (a AND b) IS b the result is TRUE if the bits in b are on in a. other bits may be on in a, but they are ignored (by the AND). hence, this is true if the set of a is greater than or equal to the set of b. eq := a IS b the result is TRUE iff the same set of bits are on in both. intersect := a AND b the result contains all of the bits that are on in both a and b +. that is, it returns the intersection of sets a and b. the & mnemonic is the C (and Perl) bitwise AND operator. the * mnemonic is for the intersection of two sets. xor := a XOR b the result contains all of the bits that are on in either or both a and b. the bits that are on in both are not included; this is the exclusive or of the two sets. the ^ mnemonic is for the C (and Perl) bitwise XOR operator. All that said, i think the only ones i have ever used are the >= and bool operators.

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re^2: Glib based forking server with root messaging by zentara
in thread Glib based forking server with root messaging by zentara

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 musing on the Monastery: (4)
    As of 2020-07-03 16:34 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found