Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Keep It Simple, Stupid
 
PerlMonks  

Comment on

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

I've studiously avoided the term "flyweight objects" as I have only ever seen it here and didn't really understand its meaning. I'll stick to "Inside-out" which only has meaning in perl terms as far as I am aware.

With regard to the example you describe, that may have made some sense in the world of 8-bit chars as you only need a pool of 256 object, but in the world of UCS, it becomes excessive I think.

Actually, I say only 256 objects, but even that doesn't make any sense to me. It might make sense in a pure OO, conceptual sense to have a seperate object for each char, but it my view its a very strange thing to do.

There are to my way of thinking only two things you can do with a char.

  • Use it. Ie. give it to some other object as a parameter.
    Eg. somestring.append('A'); or somestring.append( somechar );
  • Or ask it for its ordinal value.
    Eg. 'A'.ord(); or somechar.ord();

So even if you want to represent it at the language level as an object, in terms of what the compiler or interpreter would actually manipulate, it's just a number.

Unless I'm missing something, which is quite possible because I often do, the idea that the compiler/interpreter would manipulate a pointer to an object or worse, a handle to an object at the binary level is simple crazy?

Can you see a reason for having an object to represent each char? I mean, if your are going to allow attributes to be applied to individual chars (color, size, whatever), then pooling the objects isn't going to work because I wouldn't be able to have a red 'A' and a green 'A' at the same time.

I can see the need for being able to maintain and manipulate attributes for aggragations of chars. This string is ascii, that sting is EBCDIC, but doing this at the char level does make any sense (to me). If you could do it, then you could create aggregate strings of mixed ascii and EBCDIC and then what happens when you want to compare string 'T{ascii}h{EBCDIC}e{ascii}' with 'T{EBCDIC}h{ascii}e{EBCDIC}'--do they match or not?


Examine what is said, not who speaks.


In reply to Re: Flyweights - different meaning in perl? by BrowserUk
in thread Yet Another Perl Object Model (Inside Out Objects) by demerphq

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (11)
    As of 2014-04-25 08:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (585 votes), past polls