On Tue, Jul 13, 2004 at 10:41:32AM -0700, Austin Hastings wrote:
: --- Larry Wall <[EMAIL PROTECTED]> wrote:
: > While that probably works, I think better style would be to use a
: > comma:
: > 
: >     my $fh = open ">$filename", :excl;
: > 
: > That explicitly passes :excl to open as a term in a list rather
: > than relying on the magical properties of :foo to find the preceding
: > operator adverbially when used where an operator is expected.  
: 
: Hmm. If I must use the comma, I think I'd prefer a constant in this
: scenario:
: 
:   my $fh = open ">$filename", open::exclusive;

The problem with constants is that they're constant.  Sometimes you
don't want them to be:

    my $fh = open ">$filename", :encoding($myencoding);

: Is it reasonable to use package:: as a prefix to a block to change the
: default namespace:
: 
:   { package open; exclusive + rw; }
: 
: becomes
: 
:   open::{exclusive + rw}

Except that syntax already means something else (lookup of a symbol
in the "open::" stash).

: which then lets me say:
: 
:   my $fh = open ">$filename", open::{exclusive + rw};

If you want to call a function that will artificially multiplex several
arguments into a single argument, go ahead and call a function.
Functions are allowed to be package qualified, and they're allowed
to transmogrify random strings into package identifiers in whatever
package they like.  I don't think parameter names themselves need
to be package qualified though.  And I do think that something like
:excl is a boolean argument, not an object.  Explicitly making it
into an object (even so simple an object as a bit) seems to me like
a misfeature borrowed from C.

I can see how you're trying to use the identifier system to force
compile time checking of symbol names here, but that approach is going
to be of limited use in a language with MD.  Most parameter names will
end up being checked at runtime, and will end up throwing an exception
if no function with an appropriate signature can be found.  As I say,
you can always force checking with a function or macro of your own choosing:

    my $fh = open ">", $filename, *open::mode(:exclusive :rw);

But I think most people will prefer just to say

    my $fh = open ">", $filename, :exclusive :rw;

and take their lumps at run time.

Larry

Reply via email to