develooper Front page | perl.perl6.language | Postings from May 2001

Re: properties

Thread Previous | Thread Next
From:
Graham Barr
Date:
May 21, 2001 01:05
Subject:
Re: properties
Message ID:
20010521090419.I22335@pobox.com
On Sun, May 20, 2001 at 06:19:35PM -0400, Uri Guttman wrote:
> >>>>> "DC" == Damian Conway <damian@mail.csse.monash.edu.au> writes:
> 
> 
>   DC>         return undef Because($borked);
> 
> hmm, that is poor code as returning a real undef will break in a list
> context.

I always balk when I see someone say that. This is perfectly valid thing todo.
If the sub is defined to return a single scalar value then C<return;> is
the WRONG thing todo as it will cause problems if the result is used directly
into a list.

> so how would a value property be attached passed back to an
> empty list? what happens below:

Thats a good point. But on the other hand an empty list is neither
a variable or a value. You are returning nothing, so there is nothing
to attach it too.

But with the ability to return arrays in perl6 you should probably return
an empty array with a property attached.

> 	perm_props( $foo, 'SortCode' ) = 'ST' ;
> 
> the last one assigns the prop value with an lvalue call.

If perm_props returns a hash, then you could also do

 	perm_props( $foo ){'SortCode'} = 'ST' ;

Graham.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About