Skip to content

Commit 0b8d04d

Browse files
committed
improve README
1 parent 169d497 commit 0b8d04d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
# DynamicObjects.jl
22

3-
Provides an `@dynamicstruct` macro, allowing quickly defining structs with cached properties.
3+
Provides an `@dynamicstruct` macro, allowing quickly defining structs with derived (and optionally cached) properties,
4+
which can be defined inline using `prop = expr` using all previously or afterwards defined fields and properties, e.g. as
5+
6+
```julia
7+
using DynamicObjects
8+
9+
@dynamicstruct struct MyStruct
10+
"Standard fields are defined without an `=` sign. These can have types."
11+
a::Float64
12+
"Derived properties can use any of the other fields or properties (provided there are no cycles)."
13+
b = a + 1
14+
"Derived properties can be cached."
15+
@cached d = c + 1
16+
"Order of definition does not matter"
17+
c = b + 1
18+
"Derived properties get computed lazily and then get stored locally."
19+
e = d + 1
20+
end
21+
```
22+
423
See [https://nsiccha.github.io/DynamicObjects.jl](https://nsiccha.github.io/DynamicObjects.jl) for a non-minimal example.

0 commit comments

Comments
 (0)