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

Default-argument syntax ambiguity #2

Closed
jariji opened this issue Feb 24, 2024 · 3 comments
Closed

Default-argument syntax ambiguity #2

jariji opened this issue Feb 24, 2024 · 3 comments

Comments

@jariji
Copy link
Contributor

jariji commented Feb 24, 2024

Supposition.@check function commutative(a=intgen, b=intgen)
     add(a,b) == add(b,a)
end

Normally b=intgen would make intgen the default argument to the function, but here it's a generator for arguments to the function. What if I actually want to pass a generator as an argument? What does Supposition.@check function commutative(a=3, b=4) do -- does it error, requiring a Just(3) or what?

It seems ambiguous and potentially confusing. Perhaps it is worth considering alternative syntax, or maybe it'll grow on me.

@Seelengrab
Copy link
Owner

What if I actually want to pass a generator as an argument?

You mean if you want to use intgen itself inside of commutative? No need; just capture it, or pass a Data.Just(intgen).

What does Supposition.@check function commutative(a=3, b=4) do -- does it error, requiring a Just(3) or what?

That errors - as documented for @check, the arguments are expected to be Possibility objects:

help?> @check
  @check [key=val]... function...

[...]

  The arguments to the given function are expected to be generator strategies. The names
  they are bound to are the names the generated object will have in the test. These
  arguments will be shown should the property fail!

It seems ambiguous and potentially confusing. Perhaps it is worth considering alternative syntax, or maybe it'll grow on me.

I'm happy about any suggestions, but I'm struggling to come up with anything better than =, which clearly communicates assignment (of some form). :: doesn't work, since that's type assertion.

@jariji
Copy link
Contributor Author

jariji commented Feb 24, 2024

I'm struggling to come up with anything better than =, which clearly communicates assignment (of some form). :: doesn't work, since that's type assertion.

Yeah. /in comes to mind but I'm not sure whether it's actually better.

@Seelengrab
Copy link
Owner

Right - those also have the disadvantage of being either unicode, or requiring whitespace surrounding the operator. That's not good either, because it means this is harder to type, and the whitespace makes the entire invocation quite a bit longer. Having to write out function for the inline-definition style is already quite bloaty, especially when a few config options are passed, so I'd rather avoid forcing the arguments to be passed in longer form as well.

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