Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

RFC: Class::Moebius

by rinceWind (Monsignor)
on Jan 11, 2006 at 12:36 UTC ( [id://522420]=perlmeditation: print w/replies, xml ) Need Help??

A mathematician confided
That the möbius band is one sided.
You'll have quite a laugh
If you cut one in half,
'Cause it stays in one piece when divided.

I had an idea for a joke module, that provides möbius objects: inside out objects that are also not inside-out. However, thinking more about it, I can see that this could have practical uses.

Imagine the scenario of refactoring in-house modules for inside outedness. The modules themselves could be refactored to use Class::Std, Object::InsideOut, Class::InsideOut or whatever, but lots of existing legacy code could break if it is relying on de-encapsulation ->{foo} syntax.

Möbius objects could provide a migration path allowing the legacy code to still work, albeit generating warnings whenever encapsulation is violated, but still working.

Inside out objects tend to be implemented as a blessed scalarref, using the address or some other unique low level property (their values are not actually used). The möbius object could still use this address, but be a blessed, tied hashref or arrayref. The tie mechanism will intercept any attempts to access attributes directly, and will do the right thing, generating warnings as necessary.

What do others think? Is this idea worth pursuing? Or should it retain "joke module" status?

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re: RFC: Class::Moebius
by xdg (Monsignor) on Jan 11, 2006 at 12:59 UTC
Re: RFC: Class::Moebius
by robharper (Pilgrim) on Jan 12, 2006 at 09:43 UTC

    I think you should consider the possibility of extending your mobius module into a klein bottle module. I'm not sure if this 3d functionality should be rolled into your initial work or outside it -- perhaps there is no difference.

    Rob

      It takes 2 dimensions minimum in order to have an outside and an inside - hence möbius. If you can think of an analogy or use for the third dimension, we could well have Class::Klein.

      By the way, the limerick has another stanza:

      A mathematician called Klein
      Thought the möbius band was divine.
      He said "If you glue
      The edges of two,
      You'll get a strange bottle like mine."

      --

      Oh Lord, won’t you burn me a Knoppix CD ?
      My friends all rate Windows, I must disagree.
      Your powers of persuasion will set them all free,
      So oh Lord, won’t you burn me a Knoppix CD ?
      (Missquoting Janis Joplin)

Re: RFC: Class::Moebius
by chromatic (Archbishop) on Jan 12, 2006 at 07:29 UTC

    It sounds valuable to me. I like the idea of warning on dubious constructs, even if UNIVERSAL::isa and UNIVERSAL::can demonstrate how difficult it can be.

Re: RFC: Class::Moebius
by TomDLux (Vicar) on Jan 11, 2006 at 18:57 UTC

    Terry Pratchett would be proud of you.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

      ...the best discworld's programmer :>)))
Re: RFC: Class::Moebius
by rrwo (Friar) on Feb 18, 2006 at 14:48 UTC

    The idea is worth pursuing. But it's already been done.

    I wrote Class::Tie::InsideOut to do just that-- while completely unaware of this thread. (I posted something on London.pm was was sent a link to this.)

    It works by using tied hashes to link hash keys to variables in the class namespace, and it enforces encapsulation by only letting methods use keys when there is a variable in the same namespace.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

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

    No recent polls found