in reply to use fields


The fields pragma is a way of generating classes based on pseudohashes. As such it should give array access speed combined with hash-like flexibility. It also causes attribute names to be verified at compile time rather than run time, thus avoiding potential errors due to misspelling.

Since pseudohashes seem to have been a failed experiment the fields pragma may be the only way of guaranteeing this type of behaviour for future releases of perl.

--
John.

Replies are listed 'Best First'.
Re: Re: use fields
by perrin (Chancellor) on Jun 03, 2002 at 18:11 UTC
    Actually, since pseudohashes are being dumped, I would stay away from fields. It seems likely to change or disappear.

      Actually, since pseudohashes are being dumped, I would stay away from fields.

      I think that the intention is to support fields even if pseudohashes are abandoned. From "Programming Perl" 3rd Ed., P257:

      Pseudohashes are a new and relatively experimental feature; as such, the underlying implementation may well change in the future. To protect yourself from such changes, always go through the fields module's documented interface via its phash and new functions

      This is also the migration method proposedby the Perl6 RFC: Pseudo-hashes must die!.

      --
      John.