On Jul 2, 2009, at 3:24 PM, Chris Prather wrote:

Damnit, google turned off my Reply to All


---------- Forwarded message ----------
From: Chris Prather <perig...@gmail.com>
Date: Thu, Jul 2, 2009 at 3:18 PM
Subject: Re: AttributeHelpers naming (again)
To: Stevan Little <stevan.lit...@iinteractive.com>


On Thu, Jul 2, 2009 at 2:53 PM, Stevan
Little<stevan.lit...@iinteractive.com> wrote:
I think we have 3 categories of things, at least in my mind ...

1) Low-level immutable data structures:

 ImmutableHash
 List

These have no mutation operations available and are building blocks for the other mutable versions (see below). I doubt people actually use these ones
directly (at least not often).

2) Basic data-structures and values:

 Array
 Hash
 Bool
 String
 Number
 Bag

Array is an "extension" of List and Hash is an "extension" of ImmutableHash, both providing additional mutation operations. Bool, String and Number are just your basic values. Bag is just a poorly named and badly implemented data structure. Now, these do not really map to the Perl Scalar, Array, Hash types. However some of them do map to some of the basic Moose types (Bag
being the exception).

3) Code Patterns

 Counter

We only have one of these, but I can see other patterns like some kind of StringBuffer maybe (sure you could do that with String, but this would provide sensible defaults). The key thing about these is that they provide sensible types, default values and a subset of operations. They have a clarity of purpose which makes them more self documenting and therefor very
useful.

---

So, not sure this really helps. I wouldn't mind splitting these things into 3 different categories or something. I mean, we are breaking back compat
with MX::AH so we are free to rethink this if we want.


The only thing that really ties these together is that they're
unblessed attribute types, otherwise I think stevan's breakdowns here
are exactly it. Breaking them apart into useful abstractions and
possibly adding things like Queue, and Stack to the Code Patterns set
(which would make Array a List + Stack + Queue) would be possibly the
right idea.

Yeah, a Stack and Queue would be really useful too. I totally agree.

Perhaps we need 2 different namespaces:

  Basic::

For the #2 and #1 items.

  Pattern::

For the #3 items.

We can ignore for now that #1 and #2 are different, as doy said on #moose "... it's not like there's a particular reason to make something an ImmutableHash rather than a Hash". I think the limited direct usage of the #1 types means we can just lump them into #2.

The result is that we would have something like this:

  has foo => (traits => [ 'Basic::ArrayRef' ], isa => ArrayRef, ...);

  has web_hits => (traits => [ 'Pattern::Counter' ], ...);

As long as the traits are below the right Moose::*::*:: namespace we should be good.

Thoughts? Objections? Calls for my assignation?

(NOTE: I am not sold on these names (Basic, Pattern) they are only suggestions of how we cna break things up)

- Stevan











Reply via email to