[]interface{} from map cannot be used as []string #837
Replies: 7 comments
-
Hi, Yes, the map and filter builtin always return type is An example: array | map(# % 2 == 0 ? "even" : 42) What type of the returned expression should be? Some versions ago, Expr would try to do some type checks and try to "inherit" type of predicate in map & filter. But this lead to a lot of confusion. You're doing things right. Design your custom function to take |
Beta Was this translation helpful? Give feedback.
-
In that case, because it's untyped for some reason(?) which is illegal in a number of languages... it should be any. If both were clearly ints... int. For what it's worth, this decision is workable with AI, but feels is absolutely ridiculous.
|
Beta Was this translation helpful? Give feedback.
-
This is very strange function. Please, explain what are your trying to do? |
Beta Was this translation helpful? Give feedback.
-
I have (and my hundreds of users) been using this as a hacked up language for writing small programs using embedded structs for the last 4 years. Sort, Action, and similar were layered on-top as seperate programs but that's not needed anymore with the latest developments. The only thing that is actually missing is discrete functions within expr and this should be complete enough to move a lot of logic into the language. There's still a decent amount of odd bugs with the various representations of functions (map[string]any vs struct) but it's getting leagues better. I know it's not the intention of the library, but I'm fairly confident this is close to being turing complete if development continues over the next couple years. |
Beta Was this translation helpful? Give feedback.
-
I see. But why do you need functions inside expr? |
Beta Was this translation helpful? Give feedback.
-
I want to ship a binary that doesn't change. Then I can ship configuration files as updates. Keeping this logic in the language allows for users to modify or remove pieces they don't want, and is far more reachable for an average user. |
Beta Was this translation helpful? Give feedback.
-
I'm converting this to discussion, as I not complete anderstend what features/or bugs should be added. Let's discuss this and figure out the missing parts. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've had to write this instead which is a bit wild... what am I doing wrong?
Query:
What I expected to work...
Beta Was this translation helpful? Give feedback.
All reactions