On Sat, Jan 20, 2018 at 09:29:42PM +0100, Sawyer X wrote: > On 01/19/2018 11:24 PM, Abigail via RT wrote: > > > > But declaring variables, and never using them can still be very useful. > > > > This is how I write new() in my objects: > > > > sub new ($class) { > > bless \do {my $var} => $class; # Or bless do {\my $var} => $class > > } > > Out of curiosity, what's the benefit of this? Because all I need of an object is its memory address. "Data inheritance by default" is, IMO, an extremely lousy way of writing maintainable programs. So is using hash keys as variables (why bother with strict if you do so?) Hence, I don't do that. Instead, I store the objects attributes in lexical hashes, using the memory address of the object as key. Fieldhashes take care threads (where the memory address may change) and will clean up if an object goes out of scope. AbigailThread Previous | Thread Next