-
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
Table: mgetOrPut should be template #539
Comments
val
Somebody will have |
Note: |
@mratsim Yep, I wrote it in the "Description" - pretty sure my template is bad - it is just for the example |
Rather than change { I think it's a good use case of what what I call "named do" as mentioned here. While one can do a |
I decided to make |
@c-blake to move template discussion here unrelated to nim-lang/Nim#22994 I think that convert
|
Re: 1) Can it really be drop-in compatible / free optimization as a |
RFC: nim-lang/RFCs#539 - ~~mgetOrPutDefaultImpl template into `tableimpl.nim` to avoid macros~~ - mgetOrPut for `Table`, `TableRef`, `OrderedTable`, `OrderedTableRef` - `tests/stdlib/tmget.nim` tests update --------- Co-authored-by: inv2004 <>
Abstract
Convert table's
mgetOrPut
into template.Because the
val
has to be evaluated every call, unrelated ifkey
is int
or notMotivation
There is
template withValue
, but it looks a bit overcomplicatedDescription
The template I did in the example is not optimal - calls t[k] twice
Code Examples
Backwards Compatibility
It is the main question why I created the RFC
The text was updated successfully, but these errors were encountered: