Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pharo-contributions/pharo-talents
https://github.com/pharo-contributions/pharo-talents
pharo
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pharo-contributions/pharo-talents
- Owner: pharo-contributions
- License: mit
- Created: 2016-09-28T09:41:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-30T08:53:15.000Z (over 1 year ago)
- Last Synced: 2024-05-18T19:30:46.567Z (8 months ago)
- Topics: pharo
- Language: Smalltalk
- Size: 180 KB
- Stars: 23
- Watchers: 10
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pharo - Talents - Implementation of Talents in Pharo. Allowing us to extend the behaviour in single instances. (Language extensions)
README
# Talents for Pharo
Talents are Traits that are installed on single objects.
Pharo-Talents is a library that provides a clean implementation of Talents for Pharo Smalltalk.
It is based in a new implementation of the ClassBuilder and Traits that allows the creation of really independent classes in the system.Talents enables adding and removing behavior and state to objects, without modifying the classes.
This is an implementation of the idea presented in the work of [Ressia et al. "Talents: an environment for dynamically composing units of reuse"](http://scg.unibe.ch/archive/papers/Ress12eTalentsSPE.pdf).
## Install Talents
Talents is developed using the new Traits implementation of Pharo8. Install with:
```
Metacello new
baseline: 'Talents';
repository: 'github://tesonep/pharo-talents/src';
load.
```## Usage
### What is a Talent?
A talent is only a trait definition. This library uses regular traits as talents. This is in order of reuse the existing
infrastructure of Pharo.When you add a talent to an object all the behavior and slots of the trait used as a talent are flatenized in the object.
Any trait composition can be used to as a talent, allowing more complex talented objects.
### Adding a Talent
The library provides two ways of adding a talent to an object, the first one returns a copy of the object with the new
"enhanced" behavior and the second one modifies the receiver of the message.For creating a copy you should use:
```
newObject := anObject copyWithTalent:aTalent
```For talenting an existing object:
```
anObject addTalent: aTalent
```As any Trait composition can be used as a Talent, we can use the operations in traits.
For example, we can alias one of the selector in the talent.```
anObject addTalent: (aTalent @ {#originalSelector -> #aliasSelector})
```### Removing a Talent
Removing a talent is also straight forward.
```
anObject removeTalent: aTalent.
```If an object has more than one talent only the passed talent is removed from the object.
### Composition Operations
As said before any trait composition operation can be used as talents.
When two talents are added to an object they are sequenced in a trait composition:
```
anObject addTalent: aTalent
anObject addTalent: otherTalent
```is equivalent to:
```
anObject addTalent: aTalent + otherTalent.
```Other more complex operations can be performed using the trait algebra. For more details check the class TaAbstractComposition.