-
Notifications
You must be signed in to change notification settings - Fork 280
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
Add methods from List
/Map
to Listing
/Mapping
#683
Conversation
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
I'm missing |
e55463f
to
d689e46
Compare
@@ -128,6 +134,47 @@ public Map<Object, Object> toMap() { | |||
return properties; | |||
} | |||
|
|||
public VmDynamic toDynamic() { | |||
EconomicMap<Object, ObjectMember> members = EconomicMaps.create(this.members.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use VmObjectBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mostly nits, but also: I think we should punt these methods to another PR:
toDynamic
Mapping.entries
Mapping.values
Also, there's still many methods that's missing! Not blocking, but it would be good to have. Here's what I see that I think we can add:
indexOf
indexOfOrNull
lastIndexOf
lastIndexOfOrNull
find
findOrNull
findLast
findLastOrNull
findIndex
findIndexOrNull
findLastIndex
findLastIndexOrNull
count
foldBack
foldIndexed
reduce
min
minOrNull
minBy
minByOrNull
minWith
minWithOrNull
max
maxOrNull
maxBy
maxByOrNull
maxWith
maxWithOrNull
indexOf
pkl-core/src/main/java/org/pkl/core/stdlib/base/ListingNodes.java
Outdated
Show resolved
Hide resolved
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more suggestions, but otherwise LGTM
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
pkl-core/src/main/java/org/pkl/core/stdlib/base/MappingNodes.java
Outdated
Show resolved
Hide resolved
comments have been addressed; reviewer currently unavailable to re-review
This reverts commit a7e8dfc
c272732
to
1d2d51b
Compare
Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
Methods that "project out" of the type can be added to
Listing
andMapping
to avoid having to usetoList()
/toMap()
. Methods that result in aListing
, resp.Mapping
, are not included for performance and (lazy) semantics reasons, but methods likecontains
etc. can be defined straightforwardly.