On Sat, Aug 26, 2000 at 08:24:19PM -0500, Dave Rolsky wrote:
> This is an interesting idea.  I would think that ideally it would be
> combined with pre-declared limited keyspace hashes (which we currently
> have in a semi-crippled way with pseudohashes).  
This seems like a fairly orthagonal thing -- this is useful without that,
and that is useful without this.  It deserves an RFC of it's own (or with
other constant stuff -- take a look at RFC #83.  Suggestions on this point
would be highly useful -- they should go on perl6-language, though.

> I'd much prefer that
> these declarations happen outside the contructor, more like this maybe.  
> Also I really dislike 'rw' and such.  Let's be a little clearer:


> And this way we could drop the whole :accessible thing.  How about this:
> 
> use fields qw(
>   name :read :write
>   age  :read :write
>   peers :read :write
>   birth_date :read
> );
I really dislike this.  It takes moves this functionality from comple-time
to runtime, which is where I think it belongs.  Why, you ask?  Memonization.
You should be able to create (and destroy!) autoaccessed hash keys at
runtime.  If you want to create constant autoaccessed keys at compile time
to take advantage of consant-floding (which could make this blazingly fast
without changing the users' synthax _at_ _all_), then that's wonderful for
you, create the hash inside of a BEGIN {} block.

This synthax confuses hashes with constant keys with autoaccessed keys,
which are unrelated except insomuch as they're often useful together.

> use fields qw(
>   name :read => \&name :write => \&name
>   age :read => \&get_age :write => \&set_age
> );
Once you do that, you've lost the whole point -- you shouldn't even have to
make a function call.  Once you want to do a function call, just do it the
existing way, and ignore the autoaccessor functionality entirely.

Note that doing gets with the autoaccessor and puts with a normal function
is probably quite useful -- you normaly want to do the processing on the put
in accessor methods, and just return the value on a get.

OTOH, there are properties that it only makes sense to get and not to set,
where you'd want a :accessable('r!w') to forbid setting completely, and
precompute the value when relateds change (say, day of week).

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GU>CS d->-- s-:- a20 C++ UL+++@ P+++>+++++ L++@ E-() N o? K? w@ M-- !V
PS++ PE Y+ PGP(-) t++@ 5+ X+++ R+ tv+ b+++ DI+ D+ G e>++ h! r- y?
------END GEEK CODE BLOCK------

Reply via email to