> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> From: Piers Cawley <[EMAIL PROTECTED]>
> Date: Wed, 06 Nov 2002 12:44:39 +0000
> X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/
> 
> So, I was, thinking about the way Common Lisp handles keyword
> arguments. It's possible to declare a Lisp function as follows:
> 
>     (defun make-para ( content &key alignment font size color ) ...)
> 
> The point here is that the first argument is dealt with positionally,
> and subsequent, optional args are dealth with as keyword arguments. It
> seems to me that similar functionality might sit well with Perl 6, but
> I'm not sure I can think of a good declaration syntax. Calling syntax
> is easy:
> 
>     make_para $text, font => 'Helvetica,Arial,Whatever';
> 
> Any thoughts?

Sure.  It already does that.  But only if the caller feels like it.
If you can remember the order of all those arguments, great, but if
you can't, you can use keywords.

    sub make_para($text; $alignment, $font, $size, $color) {...}

Can be called in a lot of ways, one of which you wrote above.

I sure hope it doesn't complain that you didn't specify alignment.  I
guess that's what exists() is for.

Luke

Reply via email to