Timeline for Languages with PHP-like traits?
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 21, 2023 at 16:12 | comment | added | Fred | @user253751 Because they can, because of misunderstandings, confusion, incompetence, or anything. Conceptually is it not a is-a relationship so programmatically/contractually I don't want it to be so either. | |
May 20, 2023 at 0:39 | comment | added | Fred | @user253751 The problem is that even if I don't do it, others can still do that. | |
May 18, 2023 at 15:18 | comment | added | Fred |
@user253751 Because it lets user of my class use the class in places they shouldn't. Then a function can accept the base class as argument. The is-a relationship is misleading too, example if my class wants to include logging then I don't want it to have a is-a relationship on Logger .
|
|
May 18, 2023 at 10:42 | comment | added | amon | @Fred Seems you're more correct. I used to think of mixins as inclusion, as is the case in Ruby. However, academic literature consistently describes mixins as an abstract class that can be inherited from in multiple-inheritance languages, as exemplified by CLOS. The description by Bracha and Cook (1990) seems on point. | |
May 16, 2023 at 23:43 | comment | added | Fred | @amon My understanding is that mixin are classes that you inherit from, which creates a "is-a" relationship. If I want to include logging functionality that doesn't make my class a logger, so I don't want inheritance. | |
May 16, 2023 at 23:35 | comment | added | Fred | @user253751 The point is that in PHP the traits does not provide inheritance at all, but in other languages they often so, so when when you pass the type around, then it can get passed around to any place where the trait is asked for. My understanding is that PHP sucks the code into the class instead of inherit. | |
May 16, 2023 at 23:34 | comment | added | Fred | @svidgen I've seen this article, but what PHP calls "traits" are quite different from what other languages call traits. | |
May 15, 2023 at 20:31 | comment | added | svidgen | See en.wikipedia.org/wiki/… | |
May 15, 2023 at 19:27 | answer | added | RemixDevelopment | timeline score: 4 | |
May 15, 2023 at 17:07 | review | Close votes | |||
May 31, 2023 at 3:02 | |||||
May 15, 2023 at 15:21 | comment | added | amon | The word "mixin" does usually describe that copy-paste like relationship, without really interacting with the type system. | |
May 15, 2023 at 14:30 | comment | added | bdsl | I don't know about other languages, but PHP traits are generally described as "compiler-assisted copy and paste". | |
May 15, 2023 at 13:24 | history | asked | Fred | CC BY-SA 4.0 |