http://qs321.pair.com?node_id=11106205


in reply to Language design: direct attribute access and postponed mutators (Perl Vs Python)

Python has __setattr__:
object.__setattr__(self, name, value)
    Called when an attribute assignment is attempted. […]
  • Comment on Re: Language design: direct attribute access and postponed mutators (Perl Vs Python)

Replies are listed 'Best First'.
Re^2: Language design: direct attribute access and postponed mutators (Perl Vs Python)
by LanX (Saint) on Sep 15, 2019 at 19:40 UTC
    Thanks, but I think this will be called every time a property is accessed.

    That's like tie'ing the underlying blessed hash in Perl, then every read write access to $obj->{attribute} must be handled via FETCH and STORE.

    This must slow down OO handling considerably.

    The mechanism I described above will only affect especially "enhanced" properties and only when accessed over the external interface.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice