Tags Perl

To those of you who don't recognize the notation used in the subject, it's denoting a complex Perl data structure, namely: Array of Hash of Hash of Array of Array.

Such notation appeared after it became clear that with Perl's powerful support of hashes, arrays and references to hashes and arrays, many mind-boggling data structures are possible, and there should be some standard way to denote them.

So, today I ran into AoHoHoAoA - not my longest, but surely one of the more complex constructs:

  • In my MIX simulator, I have an array of devices: @device.
  • Each element in this array is a hash that tells about the device's file name, file handle, block size, etc. One of the fields for binary devices is $data.
  • $data is a hash reference that keeps the non-zero blocks of this device. A key is the block number, the value is the block itself.
  • A block is an array of block_size MIX words.
  • A MIX word is an array of 6 elements.
  • I gasp with horror when I have to imagine what would it take to implement such a thing in C++...

Update (2020-05-15): it's fun to re-read these old posts many years later. I find the last bullet point amusing today; while I still agree that dynamic languages are great for for rapid prototyping, I also recognize the utility of static typing for long-term readability and maintenance.