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

hash() and Hash.new currently have different API #43

Closed
lizmat opened this issue May 21, 2013 · 2 comments
Closed

hash() and Hash.new currently have different API #43

lizmat opened this issue May 21, 2013 · 2 comments

Comments

@lizmat
Copy link
Contributor

lizmat commented May 21, 2013

According to the spec at S06:3298, confirmed more or less at S04:1639, you can only specify a list (positionals) for creating a hash.

However, hash() is currently implemented as allowing any mix of Positionals and Named parameters to create a hash. rakudo/rakudo#156 makes the API of hash() consistent with Hash.new.

But apparently, this feels wrong: http://irclog.perlgeek.de/perl6/2013-05-20#i_7094884 .

So maybe the Spec should change on this. And should we find another way of creating "typed hashes" ?

@pmichaud
Copy link
Contributor

Yes, using :type and :of named arguments to create typed hashes doesn't feel right to me either. For one, "type" is too generic a name, it should probably be :ofkey or whatever the accessor of a hash's type ends up being.

Slightly better might be to pass along a prototype object used to construct the Hash (e.g., via ".new"), instead of specifying the of/key types independently.

Of course, in the final analysis, simply using .new() to create typed hashes would seem cleanest of all.

Pm

@lizmat
Copy link
Contributor Author

lizmat commented May 22, 2013

On May 21, 2013, at 3:04 PM, Patrick R. Michaud notifications@github.com wrote:

Yes, using :type and :of named arguments to create typed hashes doesn't feel right to me either. For one, "type" is too generic a name, it should probably be :ofkey or whatever the accessor of a hash's type ends up being.

Slightly better might be to pass along a prototype object used to construct the Hash (e.g., via ".new"), instead of specifying the of/key types independently.

Of course, in the final analysis, simply using .new() to create typed hashes would seem cleanest of all.

So you're saying you're not against using these typed parameters for Hash.new? So the only problem is the API change on hash() ?

Liz

@lizmat lizmat closed this as completed Jun 28, 2013
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

2 participants