[1146] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next next in chain last in chain last

Re: [COLD] scatter/optional assignments - request for discussion

daemon@ATHENA.MIT.EDU (Fri Nov 29 16:45:33 1996 )

Date: Fri, 29 Nov 1996 14:40:26 -0700 (MST)
From: Brandon Gillespie <brandon@glacier.cold.org>
To: Andrew Wilson <andrew@aaaaaaaa.demon.co.uk>
cc: Miroslav Silovic <Miroslav.Silovic@public.srce.hr>, coldstuff@cold.org
In-Reply-To: <199611291948.TAA00594@aaaaaaaa.demon.co.uk>

> I didn't look too closely at this patch, but am I right in thinking
> that the ?= operator is a simple test of existing value, rather
> then an operation which is only performed if a variable has not
> been assigned to previously?
> Perl has a useful:
> 	$foo = $bar unless $foo;
> construction, which only assigns a value to $foo if no previous
> assignment has taken place.
> Wouldn't this be logic (expressed as '$foo ?= $bar') be more useful?
> Ay (prepared to be clueless...)

IMHO no--perl's "unless" drives me up the wall (along with a few of its
other operators).  It changes the focus from left to right to right to
left simply for the fact that then it can use a cute word rather than an
operator and it supposedly makes 'sense' as you read it. Using ?= stays
left oriented, and fits in with existing operators, and is also shorter :) 
(it also 'reads' better IMHO):

   [foo, bar, 10 unless baz] = [1, 2]


   [foo, bar, baz ?= 10] = [1, 2]

And that is just in a simple scatter assignment :)