swh:1:snp:a72e953ecd624a7df6e6196bbdd05851996c5e40
Revision 2d468b1d093c68181f09f83e1108fde6a81e417b authored by Keno Fischer on 23 July 2019, 03:19:56 UTC, committed by Keno Fischer on 02 August 2019, 16:40:47 UTC
This is an alternative to #32581, that is easier to implement, but
more restrictivive. Here, the forward declaration must contain
everything except for the field types:
```
incomplete type Foo{Bar} <: Baz; end
```
with it being an error to deviate from this specification when
completing the type
```
struct Foo <: Baz; end # Error: Missing type parameter
struct Foo{A, B} <: Baz; end # Error: Too many type parameters
struct Foo{Qux} <: Baz; end # Error: Name of type parameter doesn't match
struct Foo{Bar<:Int64} <: Baz; end # Error: Bounds of type parameter don't match
struct Foo{Bar}; end; # Error supertype dosesn't match
```
This is easier because this way we have enough information for subtyping
and type application and therefor do not need to delay this until
the entire dependency graph is complete as we did in #32581.
Of course this also means that we don't get the union feature that
was requested in #269:
```
inomplete type U; end
struct A; x::U; end
struct B; x::U; end
U = Union{A, B}; #ERROR
```
However, it could of course be emulated by wrapping the union type:
```
struct U
   data::Union{A, B}
end
```

However, given the simplicity of this change and the difficulty of #32581,
this seems like the way to go for the moment. We may want to revisit all
this if we ever want to do computed field types, which will encounter similar
challenges as #32581.

Fixes #269.
1 parent 45ba7aa
History
Tip revision: 944f1809185455a1c57207983c1d0f8904343503 authored by Bogumił Kamiński on 25 March 2024, 15:18:44 UTC
Add Xoshiro reference to Random module docstring (#53784)
Tip revision: 944f180
File Mode Size
.github
base
contrib
deps
doc
etc
src
stdlib
test
ui
.appveyor.yml -rw-r--r-- 2.1 KB
.gitattributes -rw-r--r-- 67 bytes
.gitignore -rw-r--r-- 257 bytes
.mailmap -rw-r--r-- 11.0 KB
.travis.yml -rw-r--r-- 6.1 KB
CITATION.bib -rw-r--r-- 2.6 KB
CONTRIBUTING.md -rw-r--r-- 21.2 KB
HISTORY.md -rw-r--r-- 258.4 KB
LICENSE.md -rw-r--r-- 5.1 KB
Make.inc -rw-r--r-- 40.0 KB
Makefile -rw-r--r-- 28.1 KB
NEWS.md -rw-r--r-- 5.9 KB
README.md -rw-r--r-- 6.3 KB
VERSION -rw-r--r-- 12 bytes
sysimage.mk -rw-r--r-- 3.8 KB

README.md

back to top