[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Named params for Perl bindings

From: Nik Clayton <nik_at_ngo.org.uk>
Date: 2006-07-20 11:53:51 CEST

Assuming I get the time to do the work, would anyone be interested in
patches to the Perl bindings to support named parameters as well as
positional parameters?

This would mean that as well as being able to write code like:

     $ra->get_log([$paths], $rev, 1, 20, 0, 0, sub { ... });

which is a bit obtuse (quick, without access to the docs, which of those '0'
params is 'discover_changed_paths', and which is 'strict_node_history'?).
The changes I'm thinking of would let you write code like this:

     $ra->get_log({ paths => [ $paths ],
                    start => $rev,
                    end => 1,
                    limit => 20,
                    discover_changed_paths => 0,
                    strict_node_history => 0,
                    receiver => sub { ... } });

Although it's more verbose, it's much more maintainable.

Technically, this would involve any function that takes greater than 'n'
params looking to see if the first param is a hash ref, and unpacking the
parameters from the hash ref if so.

I expect (but have not yet checked) that this could probably be automated.

Any suggestions as to what an appropriate value for 'n' might be? I suspect
that '3' is a sensible minimum (i.e., any function that takes 3 or more
params should also support named parameters), but I also think that if the
work's going to happen then, for consistency, all functions should be converted.

Just to stress -- this wouldn't remove the existing calling conventions.
Just add another option.

Thoughts?

Also, having just spent 20 minutes chasing around the maze of files in
subversion/bindings, if anyone's got a "This is how SWIG is used with
Subversion" document, I'd appreciate a peek :-)

N

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 20 22:41:11 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.