-
Notifications
You must be signed in to change notification settings - Fork 23
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
Non-positional object construction (as well as positional) shorthand #550
Comments
You can't have it both ways so that the meaning of |
Furthermore the non-positional thing is trivally doable with a macro anyway and then it's explicit: |
What's wrong with Nim's scope rules ? |
I'm fine without positional, so many pitfalls on the caller side - name-matching shortcuts however, quite nice 👍👍 the scope of the name matching lookup is the object being constructed, of course. This is something that could also be expanded to function calls - ie for A macro for this defeats the purpose - the aim is to avoid extra ceremony when it's obvious what is meant (ie when name matches). This is not the case for positional arguments which are never explicitly numbered so by looking at the code, one cannot tell if the ordering is deliberate or not. Naming is always deliberate. |
It's problem ? Vec must be positional by it's mearning: ordered couple of values. You shouldn't declare object whose field initilizing order is important without I think it should just be in nep1: type Vec = object
x: int
y: int
z: int and type Vec = object
y: int
x: int
z: int must be not same decl, then mark object as {.positional.} I’m not at all sure that positional is needed somewhere other than pattern matching. For pattern matching |
Abstract
Non-positional match object fields and identifies in object constructor in general and positional with
{.positional.}
pragmaMotivation
Same as
#517
#418
Description
Main idea is match object fields and it's names (i.e it not positional)
Rules:
positional pragma
positional pragma is pragma that can set common (proc like) object calling, it useful for example when different fields have the same meaning (vectors, matrices, etc.)
Code Examples
Backwards Compatibility
No response
The text was updated successfully, but these errors were encountered: