[ 
https://issues.apache.org/jira/browse/GROOVY-11294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17812065#comment-17812065
 ] 

ASF GitHub Bot commented on GROOVY-11294:
-----------------------------------------

PaintNinja commented on PR #2044:
URL: https://github.com/apache/groovy/pull/2044#issuecomment-1915649600

   Groovy records already rely on the runtime library - the generated toList() 
and toMap() use ScriptBytecodeAdapter#createList/createMap in Groovy 4 and 
Groovy 5 snapshots (pre this PR).
   
   As explained on the mailing list, using the runtime library allows for using 
Java's faster immutable List.of()/Map.of() when possible without needing many 
changes to the AST transform or bytecode gen.
   
   After reading some of the feedback here, on the mailing list and jira, I 
better understand the importance of preferring simpler approaches and will be 
replying to the comments and re-evaluating my PR accordingly when I have time.




> Make generated toList() and toMap() methods on records return immutable 
> collections
> -----------------------------------------------------------------------------------
>
>                 Key: GROOVY-11294
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11294
>             Project: Groovy
>          Issue Type: Improvement
>          Components: record
>    Affects Versions: 5.x
>            Reporter: Oscar N
>            Priority: Minor
>
> With records having strong immutability guarantees, I believe it would make 
> sense to also have the collections returned by `toList()` and `toMap()` be 
> immutable as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to