At 7:42 AM +0000 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, not a do-nothing code.  Should we
force people to write:

    while $x-- && some_condition($x) {;}

Or should we make a counter-special case of some sort?  Or should we
take out the {} special case altogether and force people to write
hash()?

Luke

While I'm not strongly on one side or another ...

I'm inclined to make "{}" mean empty hash and {;} mean empty sub, all the time, since given common usage patterns, that would be a lot better huffman coded.

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 that Perl can natively parse it.

Moreover, I'm wanting this format to parse natively with both Perl 5 and Perl 6.

All it would contain is anonymous hashes, arrays, scalars, with a single hash being the common root container.

Now, aside from the empty hash thing, I believe that the Perl 5 and Perl 6 syntax is identical. To get around the empty hash thing, I'm simply not storing empty hashes at all (they don't actually carry information).

However, if the {} would mean empty hash in both languages, I could code more tersely and just output all hashes regardless of whether they're empty or not.

Of course, don't let this esoteric situation sway you, and I do have a workaround, but suffice it to say there's still the huffman advantage of {}.

As well as the advantage of fewer changes of Perl 5 to Perl 6 porters.

-- Darren Duncan

Reply via email to