Skip to content

Commit 61653d1

Browse files
committed
[skip ci] Polish readme
1 parent ff3dffb commit 61653d1

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://github.com/rjplevin/Classes.jl/blob/master/docs/src/index.md)
12
[![Build Status](https://travis-ci.org/rjplevin/Classes.jl.svg?branch=master)](https://travis-ci.org/rjplevin/Classes.jl)
2-
[![Build status](https://ci.appveyor.com/api/projects/status/github/rjplevin/Classes.jl?branch=master&?svg=true)](https://ci.appveyor.com/project/rjplevin/classes-jl/branch/master)
33
[![codecov](https://codecov.io/gh/rjplevin/Classes.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/rjplevin/Classes.jl)
44
[![Coverage Status](https://img.shields.io/coveralls/github/rjplevin/Classes.jl/master.svg)](https://coveralls.io/github/rjplevin/Classes.jl?branch=master)
55

@@ -13,18 +13,18 @@ If multiple types need to share structure, you have several options:
1313
1. Write out the common fields manually.
1414
1. Write a macro that emits the common fields. This is better than the manual approach
1515
since it creates a single point of modification.
16-
1. Use composition instead of inheritance: create a new type that holds the common fields
16+
1. Use composition instead of inheritance: create a new type that holds the common fields
1717
and include an instance of this in each of the structs that needs the common fields.
1818
1. Use an existing package that provides the required features.
1919

2020
All of these have downsides:
2121

22-
* As suggested above, writing out the duplicate fields manually creates maintenance challenges
22+
* As suggested above, writing out the duplicate fields manually creates maintenance challenges
2323
since you no longer have a single point of modification.
2424
* Using a macro to emit the common fields solves this problem, but there's still
2525
no convient way to identify the relatedness of the structs that contain these common fields.
26-
* Composition -- the typically recommended julian approach -- generally involves creating
27-
functions to delegate from the outer type to the inner type. This can become tedious if
26+
* Composition -- the typically recommended julian approach -- generally involves creating
27+
functions to delegate from the outer type to the inner type. This can become tedious if
2828
you have multiple levels of nesting. Of course you
2929
can write forwarding macros to handle this, but this also becomes repetitive.
3030
* Neither of the packages I reviewed -- OOPMacro.jl and ConcreteAbstractions.jl -- combine the
@@ -41,8 +41,8 @@ generated abstract types. The `@class` macro saves the field definitions for eac
4141
so that subclasses receive all their parent's fields in addition to those defined locally.
4242
Inner constructors are passed through unchanged.
4343

44-
`Classes.jl` constructs a "shadow" abstract type hierarchy to represent the relationships among
45-
the defined classes. For each class `Foo`, the abstract type `AbstractFoo` is defined, where `AbstractFoo`
44+
`Classes.jl` constructs a "shadow" abstract type hierarchy to represent the relationships among
45+
the defined classes. For each class `Foo`, the abstract type `AbstractFoo` is defined, where `AbstractFoo`
4646
is a subtype of the abstract type associated with the superclass of `Foo`.
4747

4848
Given these two class definitions (note that `Class` is defined in `Classes.jl`):
@@ -59,7 +59,11 @@ end
5959
end
6060
```
6161

62-
The following julia code is emitted:
62+
The following julia code is emitted for this example:
63+
64+
<details>
65+
66+
<summary>Macroexpand</summary>
6367

6468
```julia
6569
abstract type AbstractFoo <: AbstractClass end
@@ -95,7 +99,10 @@ mutable struct Bar{} <: AbstractBar
9599
end
96100
```
97101

98-
Note that the second emitted constructor is parameterized such that it can be called
102+
</details>
103+
<br/>
104+
105+
Note that the second emitted constructor is parameterized such that it can be called
99106
on the class's subclasses to set fields defined by the class. Of course, this is
100107
callable only on a mutable struct.
101108

@@ -110,11 +117,11 @@ Classes.issubclass(::Type{Bar}, ::Type{Foo}) = true
110117

111118
Adding the `mutable` keyword after `@class` results in a mutable struct, but this
112119
feature is not inherited by subclasses; it must be specified (if desired) for each
113-
subclass. `Classes.jl` offers no special handling of mutability: it is the user's
114-
responsibility to ensure that combinations of mutable and immutable classes and related
120+
subclass. `Classes.jl` offers no special handling of mutability: it is the user's
121+
responsibility to ensure that combinations of mutable and immutable classes and related
115122
methods make sense.
116123

117-
## Defining methods to operate on a class hierarchy
124+
## Defining methods to operate on a class hierarchy
118125

119126
To define a function that operates on a class and its subclasses, specify the
120127
associated abstract type rather than the class name in the method signature.

0 commit comments

Comments
 (0)