develooper Front page | perl.perl6.internals | Postings from August 2004

Re: Something to ponder

Thread Previous | Thread Next
From:
Aaron Sherman
Date:
August 17, 2004 15:20
Subject:
Re: Something to ponder
Message ID:
1092781215.29175.645.camel@pps
On Tue, 2004-08-17 at 16:22, Felix Gallo wrote:
> On Tue, Aug 17, 2004 at 04:08:34PM -0400, Dan Sugalski wrote:
> > 1) We're going to have MMD for functions soon
> > 2) Function invocation and return continuation invocation's 
> > essentially identical
> > 3) Therefore returning from a sub/method can do MMD return based on 
> > the return values

> $x -----\
>          \
> @mylist -+--- $obj.mymmdsub;
>          /  
> %hash --/   

How very fungible of you ;-)

Still, I think that's a nice APPLICATION, but the concept is more
flexible, if I understand it correctly. It would be something that would
look more like a cross between exception handling and a switch
statement.

I would think it would look more like (again, Perlish example):

	$sock.peername()
		does returntype(
			Net::Address::IP -> $ip {
				die "Remote host unresolvable: '$ip'";
			}, Net::Address -> $addr {
				die "Non IP unresolvable address: '$addr'";
			}, Str -> $_ {
				print "Seemingly valid hostname: '$_'\n";
			});

Of course, that's just Perl. Perhaps Python would add something that
would look like:

	returnswitch: sock.peername()
	returncase os.net.addr.ip:
		lambda ip: raise OSError, "Unresolvable %s" % str(ip)
	returncase os.net.addr:
		lambda addr: raise OSError, "Unresolvable non-IP %s" % str(ip)
	returncase str:
		lambda name: print "Seemingly valid hostname: '%s'" % name

My python skills are still developing, so pardon me if I've gotten it
wrong, and I'm just inventing os.net.addr.ip for purposes of
pseudo-code....

Is that the kind of thing you had in mind, Dan, or am I misunderstanding
how return continuations work?

-- 
☎ 781-324-3772
✉ ajs@ajs.com
☷ http://www.ajs.com/~ajs


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