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


in reply to Re: How to make Win32::API easy to use
in thread How to make Win32::API easy to use

This hits on a difference in our "Perl views" (like "world views") that has come up before. I find aliases in Perl to be a special case and so I prefer to avoid them except in certain situations.

I guess my heuristic is to avoid using them except across very short distances. The distance between the call to bind() and the definition of sub bind is pretty big, if you look at it one way.

However, Perl's read sets a precedent that I sometimes follow and this case is close enough that I could certainly make arguments that it would an appropriate use here. But I also see two reason why someone wouldn't do this. The first is avoiding user surprise as I tried to explain briefly above (and probably failed).

To make it more concrete, we don't have (w/o using C code not built into Perl) the ability to do:

my( $name, $dob, $salary ); my @arrayOfAliases= ...( $name, $dob, $salary ); ...->bind_columns( @arrayOfAlises ); # nor my( $name, $dob, $salary ); my %colMap= ( Name => aliasOf($name), DOB => aliasOf($dob), Salary => aliasOf($salary), ); ...->bind_columns( @colMap{@colNames} ); # nor ...->bind_columns( map ... );

so using aliases in your API restricts how people can use your API. (And I don't think my last example could be used even if you allow for a module including C code.)

The second reason is "comfort" of implementation, which I see fits exactly the "not thinking of your users" problem I brought up.

In Perl4 we had globs. In Perl5 we got references. In Perl6 we'll finally get full control over aliases and so they'll finally be acceptable to me to use in more general ways (I suspect).

- tye