Re: Problem with dwimmery

2005-12-26 Thread Daniel Hulme
As a third possibility, could we huffman-code do nothing clauses by leaving out the appropriate argument? That is: while $x-- some_condition($x); That's a bit too short for my liking: it is likely to lead to the traditional C undetectable bug when you write while $x--

Re: Problem with dwimmery

2005-12-23 Thread Ruud H.G. van Tol
Jonathan Lang: could we huffman-code do nothing clauses by leaving out the appropriate argument? while $x-- some_condition($x); Heheh, I often code like that, and then silence the complaint by adding the {}. -- Grtz, Ruud

Re: Problem with dwimmery

2005-12-23 Thread TSa
HaloO, Nicholas Clark wrote: Well, I assume that the do-nothing sub is assigned into the variable, and gets re-evaluated each time the variable is use. Which would mean that you'd get a new (different) empty hash each time. Whereas an empty hash constructor gives you a hash reference to keep.

Re: Problem with dwimmery

2005-12-23 Thread Nicholas Clark
On Fri, Dec 23, 2005 at 10:43:23AM +0100, TSa wrote: HaloO, Nicholas Clark wrote: Well, I assume that the do-nothing sub is assigned into the variable, and gets re-evaluated each time the variable is use. Which would mean that you'd get a new (different) empty hash each time. Whereas an

Re: Problem with dwimmery

2005-12-23 Thread Larry Wall
On Thu, Dec 22, 2005 at 03:19:03PM -0800, Jonathan Lang wrote: : As a third possibility, could we huffman-code do nothing clauses by : leaving out the appropriate argument? That is: : : while $x-- some_condition($x); : : or : : loop ( ; some_condition($x) ; $x--); We could, except that

Re: Problem with dwimmery

2005-12-22 Thread Darren Duncan
At 7:42 AM + 12/22/05, Luke Palmer wrote: Recently, I believe we decided that {} should, as a special case, be an empty hash rather than a do-nothing code, because that's more common. However, what do we do about: while $x-- some_condition($x) {} Here, while is being passed a hash,

Re: Problem with dwimmery

2005-12-22 Thread TSa
HaloO, Luke Palmer wrote: Recently, I believe we decided that {} should, as a special case, be an empty hash rather than a do-nothing code, because that's more common. Ups, is that distinction needed eagerly? Wouldn't the return value of a do-nothing code return a value that when coerced into

Re: Problem with dwimmery

2005-12-22 Thread Juerd
Luke Palmer skribis 2005-12-22 7:42 (+): Recently, I believe we decided that {} should, as a special case, be an empty hash rather than a do-nothing code, because that's more common. I think it should be both. my $foo = {}; $foo(); # It was a sub my $foo = {}; $foobar =

hashes and subs [was: Re: Problem with dwimmery]

2005-12-22 Thread Michele Dondi
On Thu, 22 Dec 2005, TSa wrote: Luke Palmer wrote: Recently, I believe we decided that {} should, as a special case, be an empty hash rather than a do-nothing code, because that's more common. Hmmm, OTOH a hash is a special kind of function, so it may also be convenient to think of {

Re: Problem with dwimmery

2005-12-22 Thread Michele Dondi
On Thu, 22 Dec 2005, Juerd wrote: while $x-- some_condition($x) {} Here, while is being passed a hash Why? Doesn't while's signature specifically prescribe a sub there, and if it does, then wouldn't it be just a bit too silly to stick to {} being a hash? Well, as hinted in my other

Structured data format [was: Re: Problem with dwimmery]

2005-12-22 Thread Michele Dondi
On Thu, 22 Dec 2005, Darren Duncan wrote: On a separate but related matter, I'm in the position of wanting to do something unusual, which is create a data file format whose content is executable perl code that defines a data structure, a hash of whatever. Kind of like how XML works except

Re: Problem with dwimmery

2005-12-22 Thread Austin Frank
Luke Palmer wrote: However, what do we do about: while $x-- some_condition($x) {} Here, while is being passed a hash, not a do-nothing code. Should we force people to write: while $x-- some_condition($x) {;} Do we still have a yada yada yada? Could it be used to

Re: Problem with dwimmery

2005-12-22 Thread TSa
HaloO, Juerd wrote: I think it should be both. So do I. my $foo = {}; $foo(); # It was a sub The postfix () is valid syntax irrespective of the former assignment, right? my $foo = {}; $foobar = 1; # It was a hash Would you expect the second line to work witout the

Re: Structured data format [was: Re: Problem with dwimmery]

2005-12-22 Thread Darren Duncan
At 3:40 PM +0100 12/22/05, Michele Dondi wrote: On Thu, 22 Dec 2005, Darren Duncan wrote: On a separate but related matter, I'm in the position of wanting to do something unusual, which is create a data file format whose content is executable perl code that defines a data structure, a hash

RE: Problem with dwimmery

2005-12-22 Thread Joe Gottman
-Original Message- From: Austin Frank [mailto:[EMAIL PROTECTED] Sent: Thursday, December 22, 2005 10:58 AM To: Luke Palmer Cc: perl6language, Subject: Re: Problem with dwimmery Do we still have a yada yada yada? Could it be used to differentiate between the two cases

Re: Problem with dwimmery

2005-12-22 Thread Nicholas Clark
On Thu, Dec 22, 2005 at 02:53:39PM +0100, TSa wrote: HaloO, Luke Palmer wrote: Recently, I believe we decided that {} should, as a special case, be an empty hash rather than a do-nothing code, because that's more common. Ups, is that distinction needed eagerly? Wouldn't the return value