Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random hash order in .perl method on Moar and JVM #3751

Closed
p6rt opened this issue Mar 22, 2015 · 8 comments
Closed

random hash order in .perl method on Moar and JVM #3751

p6rt opened this issue Mar 22, 2015 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Mar 22, 2015

Migrated from rt.perl.org#124148 (status was 'resolved')

Searchable as RT124148$

@p6rt
Copy link
Author

p6rt commented Mar 22, 2015

From @dwarring

The perl method on Rakudo/MoarVM currently outputs has entries in a random order​:

  % perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
  {"c" => 30, "a" => 10, "b" => 20}
  % perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
  {"a" => 10, "b" => 20, "c" => 30}

JVM otoh, does seem to order consistantly​:

  % perl6-j -e'say { :a(10), :b(20), :c(30) }.perl'
  {"a" => 10, "b" => 20, "c" => 30}
  % perl6-j -e'say { :a(10), :b(20), :c(30) }.perl'
  {"b" => 20, "c" => 30, "a" => 10}

S02 doesn't have an opinion on hash ordering - http://design.perl6.org/S02.html#The_.perl_method

I'm in the habit of using the .perl method as part of the normal development/debugging progress, but I find that the MoarVM behavior can be a bit taxing in practice.

Could the MoarVM .perl method also order hash entries?

@p6rt
Copy link
Author

p6rt commented Mar 22, 2015

From @dwarring

Correction​: both MoarVM and JVM are re-ordering hash entries. Changing the title of this ticket.
On Sun Mar 22 12​:49​:22 2015, david.warring wrote​:

The perl method on Rakudo/MoarVM currently outputs has entries in a
random order​:

% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{"c" => 30, "a" => 10, "b" => 20}
% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{"a" => 10, "b" => 20, "c" => 30}

JVM otoh, does seem to order consistantly​:

% perl6-j -e'say { :a(10), :b(20), :c(30) }.perl'
{"a" => 10, "b" => 20, "c" => 30}
% perl6-j -e'say { :a(10), :b(20), :c(30) }.perl'
{"b" => 20, "c" => 30, "a" => 10}

S02 doesn't have an opinion on hash ordering -
http://design.perl6.org/S02.html#The_.perl_method

I'm in the habit of using the .perl method as part of the normal
development/debugging progress, but I find that the MoarVM behavior
can be a bit taxing in practice.

Could the MoarVM .perl method also order hash entries?

@p6rt
Copy link
Author

p6rt commented Mar 23, 2015

From @pmichaud

On Sun Mar 22 13​:04​:21 2015, david.warring wrote​:

Could the MoarVM .perl method also order hash entries?

Requiring .perl to order hash entries ought to be a language/specification change, rather than something that individual compilers do on their own. Otherwise programmers may falsely rely on a compiler-specific behavior.

To have this considered as a language feature, add an issue to GitHub​: https://github.com/perl6/specs/issues

Pm

@p6rt
Copy link
Author

p6rt commented Mar 23, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 23, 2015

From @dwarring

On Mon Mar 23 06​:48​:38 2015, pmichaud wrote​:

On Sun Mar 22 13​:04​:21 2015, david.warring wrote​:

Could the MoarVM .perl method also order hash entries?

Requiring .perl to order hash entries ought to be a
language/specification change, rather than something that individual
compilers do on their own. Otherwise programmers may falsely rely on
a compiler-specific behavior.

To have this considered as a language feature, add an issue to GitHub​:
https://github.com/perl6/specs/issues

Pm

Have opened issue Raku/old-design-docs#88
- David

@p6rt
Copy link
Author

p6rt commented May 10, 2015

From @dwarring

The .perl method on Hashes has been reworked in the latest rakudo. Looks good! (Looks Good!!).

% perl6-m --version
This is perl6 version 2015.04-204-ga040b1a built on MoarVM version 2015.04-62-g052aca0
% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{​:a(10), :b(20), :c(30)}
%
% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{​:a(10), :b(20), :c(30)}

Hashes currently appear to be ordered.

On Mon Mar 23 11​:09​:33 2015, david.warring wrote​:

On Mon Mar 23 06​:48​:38 2015, pmichaud wrote​:

On Sun Mar 22 13​:04​:21 2015, david.warring wrote​:

Could the MoarVM .perl method also order hash entries?

Requiring .perl to order hash entries ought to be a
language/specification change, rather than something that individual
compilers do on their own. Otherwise programmers may falsely rely on
a compiler-specific behavior.

To have this considered as a language feature, add an issue to GitHub​:
https://github.com/perl6/specs/issues

Pm

Have opened issue Raku/old-design-docs#88
- David

@p6rt
Copy link
Author

p6rt commented Oct 27, 2015

From @coke

On Sun May 10 13​:20​:24 2015, david.warring wrote​:

The .perl method on Hashes has been reworked in the latest rakudo.
Looks good! (Looks Good!!).

% perl6-m --version
This is perl6 version 2015.04-204-ga040b1a built on MoarVM version
2015.04-62-g052aca0
% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{​:a(10), :b(20), :c(30)}
%
% perl6-m -e'say { :a(10), :b(20), :c(30) }.perl'
{​:a(10), :b(20), :c(30)}

Hashes currently appear to be ordered.

On Mon Mar 23 11​:09​:33 2015, david.warring wrote​:

On Mon Mar 23 06​:48​:38 2015, pmichaud wrote​:

On Sun Mar 22 13​:04​:21 2015, david.warring wrote​:

Could the MoarVM .perl method also order hash entries?

Requiring .perl to order hash entries ought to be a
language/specification change, rather than something that
individual
compilers do on their own. Otherwise programmers may falsely rely
on
a compiler-specific behavior.

To have this considered as a language feature, add an issue to
GitHub​:
https://github.com/perl6/specs/issues

Pm

Have opened issue Raku/old-design-docs#88
- David

.perl on hashes is now sorted - all the tests in S32-hash/perl.t implicitly cover this condition.

Resolving ticket.
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 27, 2015

@coke - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant