« first day (4897 days earlier)      last day (276 days later) » 

13:10
@bwoebi Do you have an example of what you mean? I don't quite follow. (If I understand what you're saying, I don't know of a language that does that.)
 
2 hours later…
15:03
@Crell I think you have understood what I'm saying - basically establishing the valid template types for an instance at runtime and fixate an upper bound of validity according to type checks the class has been subject to. E.g. having a container $obj, then doing $obj->push(new A); $obj now is a container<required-types(A), permitted-types(mixed)>. Then doing $obj->push(new B); - Now it's a container<required-types(A|B), permitted-types(mixed)>.
Then we pass $obj to a function expecting container<? extends A|B|C> (to use java syntax for covariance). The type changes to container<required-types(A|B), permitted-types(A|B|C)>. If we now do a $obj->push(new D); it will fail. Moving the container to a function accepting container<A|B|D> will also fail. … Something along these lines. It's complex to wrap the head around that TBH.
 
1 hour later…
16:14
Ah, I see. For objects, that seems unwise. The whole point of the typing is to allow compile-time or static-analysis time verification that things won't break. Doing it at runtime means, well, it won't break until runtime.
Arnaud is/was working on doing something like that for arrays, though. So you could type against `function foo(array<int> $is)` and then do `$a[] = 1; foo($a)` and it would pass, whereas `$a = [1, 'beep']` would fail at runtime. I'm still not convinced that's wise or performant.
Derick and I have discussed formal collection objects in core (I did a lot of language survey research on it last year), but that's on hold for now pending the results of Arnaud's generics research, as it would be way better to have real generics than a hacky semi-generics for collections only. (That's something Derick managed to make work, but real generics are better.)
16:29
@Crell It probably needs to be a mix, just as existing typing is already a mix.
If there was a language-official static type checker tool, I would be happy to have generics be only verified at analysis time (not runtime) initially. I know others wouldn't want this. But something big like this probably needs phases, and I think that's an acceptable phase 1.
Also, I think having a language official analysis tool would be great.
Part of what makes Rust so great is the ecosystem. Having official tools really does help so many things.
 
1 hour later…
17:42
@Crell Yes, that's the PHP way to do things. And that's what you have static analysis for (psalm for example). The good part on that is that static analysis can be continuously improved, taking values, ranges, even some assertions on the data into account.
The runtime types are there to have hard guarantees, i.e. actual type assertions and the ability to optimize on it.
What I really want is asserting Collection<Foo> is containing only Foo when I'm passed the collection. I don't care about the provenance of the collection.
It behaves like a Collection<Foo>, so it is a Collection<Foo> for my purposes.
 
1 hour later…
19:06
I don't mean compile-time only generics / erased generics. I mean the type of an object changing out from under the code and so not being known even though it's declared, that is what strikes me as unwise.
And I am just as interested in "if it's a Collection<Foo>, then thou shalt not put something into it that is not a Foo" as in "I only accept Collection<Foo>".
If not moreso.

« first day (4897 days earlier)      last day (276 days later) »