-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
addpattern def
with no prior match def
#718
Comments
Yeah, that's a good point. Should pretty easy to just make |
I have thought about this a bit more, my question is: if unification is easy as you say, and with |
@yggdr I'm not a fan of that. I think it's pretty confusing given that normal Python function definitions do overwrite each other. It could be quite easy to expect overwriting behavior, not realize you're shadowing some other function in an enclosing scope, and up with a very hard to debug issue. |
This is now live on |
Hmm, yeah, I see this could be an issue in a language where, unlike Elixir, pattern matching functions are just one of a few options. Ok, |
With #833, this should be deprecated and show a warning if you do it, since |
Deprecation warning has been added; just needs documentation. |
addpattern def
with no prior match def
See Coconut's [documentation](http://coconut.readthedocs.io/en/develop/DOCS.html) for more information on all of the features listed below. Language features: * #833: New `case def` syntax for more easily defining pattern-matching functions with many patterns. * #811: New `f(name=)` syntax as a shorthand for `f(name=name)`, replacing the now deprecated `f(...=name)` syntax. * #836: New `CoconutWarning` built-in used for Coconut runtime warnings. Compiler features: * #837: Coconut will now warn about implicit string concatenation and disable it completely with `--strict`. * #718: Coconut will now warn about use of `addpattern def` without a prior `match def`. This was a previously-supported feature to make pattern-matching functions with many patterns easier to write, but the new recommended way to do that is now via `case def`. * #785: Initial [pyright](https://github.com/microsoft/pyright) support via the `--pyright` flag. Bugfixes: * #839, #840: Fixed some f-string parsing issues. * #834: Fixed `len` of empty `zip` objects. * #830: Improved use of colored output. * #757: Improved PEP 695 support on Python 3.12.
I recently got back into coconut, and I like the improvements and additions. It is now possible to use the
addpattern def
syntax to add additional pattern matching functions with the same name. Unfortunately, withaddpattern def func
being merely sugar for@addpattern(func)
right now, this means that whatever is the first function cannot use theaddpattern def
syntax, it has to usematch def
. So when refactoring one has to keep that in mind.Now I understand how that developed historically, but I think it would be worthwhile thinking about unifying the syntax here, so that either
addpattern def
also works in the first instance, ormatch def
incorporates the@addpattern(func)
functionality on subsequent function definitions.The text was updated successfully, but these errors were encountered: