Indeed I found these links interesting especially in that they show that the concept is not perl-specific as I would have naively thought.

It seems to me that the basic aspect on which most references that were given to me concentrate is that of caching, which supports the actual "light" nature of these objects, as of the name attribution.

However it doesn't seem to me that the typical example one sees about them is really any lighter than "standard" objects. Granted, I see how one could make them so, but that's a different story. Perhaps flyweight objects are really flyweight in other OO {models,languages}.

Note: With the above I mean that the typical perl example of a constructor is:

sub new { my $class = shift; my $id = bless [] => $class; $data{$id} = { foo => undef, bar => undef }; # ... $id; }
or (to speak about Inside-Out):
sub new { my $class = shift; my $id = bless [] => $class; $foo{$id} = undef; $bar{$id} = undef; # ... $id; }
Sometimes one sees \(my $bogus) instead of [], but basically in these typical constructors a unique id is associated to each object, different for all of them.

Side note - OT

While I think that WiKi's such as the referenced one are generally precious resources, I also find their extremely hypertextual nature occasionally confusing and annoying: I tend to have the impression that there may be some relevant node that I missed. Sometimes a slightly more sequential organization would come useful.

Now one -well, I for one- wonders how an ordering could be find (maybe automatically or semiautomatically) in a document that is inherently hypertextual as to make it into a sequential thing...


In reply to Re^2: Doubt about fly-weight objects. by blazar
in thread Doubt about fly-weight objects. by blazar

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!
  • 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, details, 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, summary, 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.