Partial Record Field Access #620
Replies: 2 comments 2 replies
-
At the moment, you may know it's there but the type system does not. It only ever sees that it has some |
Beta Was this translation helpful? Give feedback.
-
Thanks I appreciate the extra context. I think my misunderstanding of some things made my comment less clear, the situation I am thinking about is when we know the Data is of type MyDatum already and I'd like to access prop_a. So in this case I was wondering if it was possible to skip the pattern match, the thought came from seeing a similar situation in plutus tx code where an accessor function is called on the MyDatum type for a property that was present on all versions of MyDatum, but I wouldn't be surprised if as you say you're not actually saving yourself anything here in terms of performance. Ktorz mentioned this could potentially be a kind of syntactic sugar to avoid doing a "let when is" to get the property, which I think would also be beneficial but probably not high priority |
Beta Was this translation helpful? Give feedback.
-
I have a scenario where I am spending 2 outputs from a script, one output will have Datum1 and one will have Datum2, but in this scenario the only thing I care about is prop_a from each. It would be convenient if I didn't have to determine the type of the datum and cast the Data object to the correct type but could instead just access prop_a which I know will be there either way. I'm not sure if this would provide a performance benefit (possible to avoid type casting the whole object?) or just give a more concise way to access the desired property in this scenario.
Beta Was this translation helpful? Give feedback.
All reactions