Markus Peter writes:
> > use %record{
> >
> >         $\interest_earned += $\balance * $\rate_daily;
> > };

Guys, where in the sweet name of Jesus did this awful syntax
come from?

For a start,

  %start{ .... }

is only analogous to a slice operation.  It has no precedent in
Perl.

Normally what you'd say is:

  with (%record) {
    ....
  }

(look at me, using Larry's new ... operator :-)

Second, the backslashes in front of the variables is muy ugly.
I'm not sure what they're there for.  I understand you want to
get to the fields of your hash, but that isn't the way to do it.

I'd tie with() into predeclared structures.  If you've declared the
fields of the hash, then that lets you set up the lexical knowledge at
compile-time.  After all, if you wrote code to access the lexical
aliases for fields of the hash, then you must have known the fields
when you wrote the code.

Ideally you'd find a way to name your structures:

  # making this part up
  struct Person => [ qw(Name Age Height Weight) ];
  # but once you have a named structure, you can say ...
  my Person %nat;
  with (%nat) {
    $Name = "Nathan";   # rewritten to $nat{Name} at compile-time
    ...
  }

It's kinda like fields.pm only for real hashes not pseudohashes.

Nat

Reply via email to