H.Merijn Brand wrote:
A bit more thought leads to better portability ...

my $hash = {

    meta => {
        f_dir       => "data",
        f_schema    => undef,
        f_ext       => ".csv/r",
        f_encoding  => "utf8",
        f_lock      => 1,
        },

Something very important here, arguably the most important thing to get right at the start, is that the API has to be versioned.

We have to start off with a ridiculously simple metaformat, such as simply a 2-element array. The first element of this array declares the version of the format of the metadata, where that is provided as the second element.

For example:

  my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
    meta => [['DBI','http://dbi.perl.org/','0.001'],{
      ...
    }],
  }) or die DBI->errstr;

Or if that's too complicated, then:

  my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
    meta => ['0.001',{
      ...
    }],
  }) or die DBI->errstr;

The format here is based on that used by Perl 6 for fully-qualified Perl or module names, with parts [base-name, authority, vnum]. Something similar is also mandated by Muldis D for starting off code written in it.

For that matter, look at the META.yml files bundled with Perl modules these days, which declare the version of the spec they adhere to.

The point is that we will give ourselves a lot of room to evolve cleanly if we start using declared versions in the beginning, so that any subsequent version of DBI can interpret the user arguments unambiguously to their intent, because the users are telling them, the input is in this version of the format.

The second element can even change over time, say from a hash-ref to an array-ref or vice-versa, depending what the first element is.

So I strongly suggest starting from the point of mandating declared versions and go from there.

-- Darren Duncan

Reply via email to