Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: How to make Win32::API easy to use

by tye (Sage)
on Jun 02, 2004 at 20:56 UTC ( [id://359742]=note: print w/replies, xml ) Need Help??


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        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://359742]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found