develooper Front page | perl.perl6.language | Postings from March 2005

Re: Parameter and trait questions - just how 'only' _is_'read-only'?

Thread Previous | Thread Next
From:
Uri Guttman
Date:
March 26, 2005 22:38
Subject:
Re: Parameter and trait questions - just how 'only' _is_'read-only'?
Message ID:
x7is3dioep.fsf@mail.sysarch.com
>>>>> "LW" == Larry Wall <larry@wall.org> writes:

  LW> : then how would you assign undef to the only element of the
  LW> array? would this : be needed:

  LW> : 
  LW> : 	@a = ( undef ) ;	# same as p5?
  LW> : 
  LW> : vs.
  LW> : 	@a = undef ; 		# like undef @a in p5?

  LW> Those would do the same thing under the current proposal, since
  LW> they're both in list context.  If you really, really want a scalar
  LW> undef value in list context, you could always say

  LW>     @a = scalar(undef);

that works. i am starting to see what you mean by undef knowing about
context.

  LW> : in fact i would like to
  LW> : stop allowing undef as a function with args and have it only return a
  LW> : scalar undef value. there should be a different op to truly make an
  LW> : aggregate undefined (and i still don't see a need for that, emptying it
  LW> : is all that i ever think is needed).

  LW> We could certainly split out a separate undefine() function.  We could
  LW> even give it an optional argument that says *why* it's undefined, turning
  LW> it into an unthrown exception, basically.  We could use such a function
  LW> to create interesting values of undef that are context sensitive.

that split makes sense as you are now using undef as a special (or as
you say below unexpected) value. so it shouldn't also be overloaded as a
function operating on variables. just doing the split will make me
happier (if you are so benevolent as to care about my happiness :).

  LW> : in my world undef is a scalar value and nothing else. how do you see it
  LW> : in p6?

  LW> undef is not a scalar value, it is the explicit *absence* of a value
  LW> where you expected one.  In Perl 6, undef is the Bearer of Bad News.

oy! i feel the pain of the late night phone call. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

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