RE: PROTOPROPOSAL FOR NEW BACKSLASH was Re: implied pascal-like"w ith" or "express"

[email protected] ("Brust, Corwin")
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
Correct me if I'm wrong here, but I think what David wanted was an easy way
to reference other keys of an hash while creating one, ie:

How to do this, in a line:

	%h = (  first => 10 );
	$h{second} = $h{first} * 2;

Because, as I'm sure you know, this code (when run w/out strict):

	my %h = (
	         first => 10,
	         second => $h{first} - 5
	         );
	print map { qq[$_ => $h{$_}\n] } keys %h;

Gives us this output:

	first => 10
	second => -5

<snip>
-----Original Message-----
From: Nathan Torkington [mailto:[email protected]]
Sent: Tuesday, August 22, 2000 8:50 PM
[...]
So in my opinion, you haven't really come up with a strong argument
against:
</snip>

Perhaps \-> or \> might work:

	%h = (
		first          # a normal key
			=> 10    # with a vililla value

		second         # another key
			\>first  # value references the value of 
			         # the 'first' key of this hash
		);

I realy don't have any ideas of what a workable syntax would be but I do
think that being able to access already defined keys within the current hash
defination would be useful.

-Corwin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.