When does it pay off to use S4 methods in R programming

前端 未结 7 1323
不知归路
不知归路 2020-12-12 13:55

I program regularly in R in a professional context, and I write packages for clients or co-workers as well. Some of the programmers here have a Java background and insist on

7条回答
  •  再見小時候
    2020-12-12 14:22

    My experience is in line with yours, so I use S3 exclusively.

    To clarify: S4 has some slick features (e.g. dispatch on multiple arguments and slot type-checking), but I have not encountered a situation where the features outweighed the costs. Examples of the costs include: any slot change requires a full object copy and (potentially worse) the on-going changes to S4 Methods.

    In short, I like the idea behind S4 but I would wait for it to mature before using it in my own code.

提交回复
热议问题