« first day (4909 days earlier)      last day (46 days later) » 

12:03 AM
@TimWolla Thanks @TimWolla, lots of good info here. If MT is really soft-deprecated, a note to that effect in the documentation would not go amiss. Something to the effect of, "This engine/method is not recommended and may be deprecated in the near future"
 
 
4 hours later…
4:32 AM
@IluTov I don't understand why we're not on the same wavelength, here. It's not any different from a by-value array. The "reference" which modifies the value sees the change, and the others see the old value. Sure, replace() doesn't have to return the old value in our case, maybe even shouldn't, but I don't see why we wouldn't have it, same with take()?
I mean, clear() type operations are common on container type. Option is a special sort of container. I don't understand why you wouldn't want these kinds of methods?
It's not like you'd take away $vec[0] = 1 or something? Or $vec->pop()?
 
 
1 hour later…
Wes
5:58 AM
\o
how are you doing folks?
do you folks remember if $obj instanceof Foo will cause Foo to autoload? I mean if $obj is a Foo then Foo will be already loaded, and if it's not already loaded then $obj can't be a Foo
 
Wes
6:55 AM
so after i checked, looks like it doesn't. but are there any edge cases? traits or interfaces maybe?
 
 
2 hours later…
9:14 AM
Good Morning!
Well... after a year and almost two months in an Interim VP role at my organization, I was finally given the official promotion as a VP. \o/
Longest job interview ever!
 
9:36 AM
congrats!
 
Thanks!
 
10:18 AM
Congrats \o/
 
10:39 AM
\o/
 
 
3 hours later…
1:53 PM
@QuolonelQuestions I'd rather not add such a note to the docs without an actual vote. And for an actual vote, I'd rather actually deprecate the global Mt19937 (i.e. mt_rand) first. With the existing warning note, folks are already made aware that both Xoshiro256** and the Pcg128OneseqXslRr64 are better choices.
 
Sure. Well it was useful context for me, anyway. Under what circumstances might one choose PCG over xoshiro?
 
@QuolonelQuestions The PCG has a smaller state (just 128 bits, instead of 256 bits), supports arbitrary jump distances and supports arbitrary seeds (Xoshiro's state may not be all-zero).
 
Why would a smaller state ever matter?
 
Memory usage. As an example, I've recently updated the underlying RNG for the session garbage collection from the internal “Combined LCG” (which I'd like to remove from the code entirely, it's even worse than Mt19937) to the PCG.
PCG's smaller state size allowed me to keep the size of the structure containing the session globals within a single cache line (i.e. 64 bytes), whereas using Xoshiro would've increased the size above 64 bytes into a second cache line.
I misremember: It was already larger than a single cache line, but it allowed me to keep the size of the struct, after reordering its members to reduce the number of holes.
 
Is that really relevant to PHP users or just internals contributors?
 
2:05 PM
@LeviMorrison Because they are both monads :p
 
@QuolonelQuestions Probably much less relevant as a userland developer. Both Xoshiro and PCG are fine choices there.
 
@TimWolla Doesn't xoshiro also support arbitrary seeds?
It rather seems that way to me
 
> If a string seed consists of 32 NUL bytes ("\x00"), a ValueError will be thrown.
 
That seems like a generally inconsequential limitation
 
It's a failure mode you need to be aware of depending on how you perform the seeding.
 
 
1 hour later…
3:22 PM
@LeviMorrison When you say value semantics, do you mean "passes by value" or "is immutable"? Because we're entering into territory where a variable could be one or the other or both.
 
@Crell Let's just say PHP array semantics, I guess.
They can be similar, I get they are sort of the same if you squint.
 
Well, no, they're not the same. That's the point. :-)
We can already do immutable reference objects (readonly). An immutable pass-by-val object seems... kinda pointless, since it would never separate/clone anyway.
(Unless data classes get some other behavior beyond that, which is a possibility.)
But for enum ADTs, I'm more inclined toward them being immutable than being mutable-pass-by-value.
 
Mutability is important. An option is a container like a vec, except it holds exactly zero or one value instead of zero or more. An immutable vec has a place in the world, but it's not nearly as used as a mutable ones.
If I had to choose between implementing an Option as immutable enum ADT, or as a pass-by-value, array-like value type, I would do the latter. Definitely.
 
IMHO you shouldn't be changing the backing value of an option, but return a new option
 
But then you've no way to enforce that it can only be Some or None.
 
3:29 PM
Option is an ADT
Same as result really
 
If you have Options as members of a class, it's likely you have a single reference to the Option. Making a new one and replacing it is the same result as a value type, except less efficient and more annoying to the programmer.
 
For Vec, Derick and I spent time last year looking into collections generally in a number of languages. My conclusion is that we would want to model on Kotlin, which has both mutable and immutable versions of lists, sets, and maps, and easy ways to convert between them.
 
@LeviMorrison That's bad design
 
@Girgias What is?
 
Why the heck are you modifying an option value in-place??
 
3:31 PM
@LeviMorrison Storing an option as a property?
 
@Crell Why do you think making a new one and re-assigning it is any different?
 
That makes utterly no sense to me
 
@Girgias I'm confused... why would I not use Options as members?
 
You have Maybe/Option of something, not a thing that maybe has something
@LeviMorrison Why would you? I don't see why one would do that
 
@Girgias Oh, that's easy. My go-to example is a command-line argument parser. You have explicit on/off, or omitted. With an Option<bool> you can represent all 3 states.
 
3:33 PM
An option is not really the same thing as val|null. They're often used to solve the same problem space, but they're not blindly interchangeable.
 
Like... optional things happen a lot. This is why I'm confused.
 
@LeviMorrison what? That's not the proper way to encode a tri-state
 
@Girgias Depends on the thing, really.
 
Sure, but once you've parsed your command line args into an object (value or otherwise), it should be immutable.
 
I'd argue that no never, if you can have 3 states then you need to use an enum with 3 cases
 
3:35 PM
@Crell ... why?
 
Why should your CLI options change during the program execution?
 
Proxying commands?
 
Huh?
 
Yeah I don't get this
 
You guys have never had a shell script which accepts args, does some modification, and delegates to something else? Now imagine you wrote it in PHP.
 
3:37 PM
But the delegation is a "new" command
 
Yeah, I'd just build a new args argument for that.
 
If I'm done with the old ones, why should I be forced to make new ones? It's less efficient.
 
That's a problem for the compiler
 
The thing about pass-by-value semantics, is that you will get new objects when you mutate them, but only if it really needed to. That's literally the VM in action doing it for you! (unintentional refcounts aside)
 
Like, exec:all is just a loop over exec:a, exec:b, and exec:c? I'd design it such that either I didn't need to have a different args object for each one, or I'd just suck it up, make it immutable, and build myself some easy with-er() methods.
 
3:39 PM
@Girgias Options as members totally make sense to me, just like nullable members make sense to me.
 
T|null is definitely convenient in the current language, when you can get away with it. But sometimes T can also be null, and you need to know the difference. So use an Option<T> in these cases. Any place you could use a T|null you could also use an Option<T>.
 
Though with PHP a nullable type is mostly doing the job of an Option, because null is part of the type (compare to Java where it isn't).
 
Though, one thing I'd want to do with data objects is insist that their properties had to be primitives or data objects, to avoid weirdness. Which would preclude an enum ADT from being used as a property, unless it was also a data object.
But that still makes little sense to me, as ADTs are built on enums in most peer languages for a reason: It's a finite set of values. That's kinda the thing. I suppose we could make enums also data values; if they're immutable then it wouldn't actually do much, other than making them legal in data objects.
(I should note here that I have little use for Option in practice; mostly I want Result, and IMO it would be better implemented as a dedicated syntax a la Midori through checked exceptions, as I have previously discussed. :-) )
 
@TimWolla I mean I have opinions because I come from the mathematical perspective
 
@Crell Except once you go full ADT it's no longer a finite set of values, because the members of each case may be infinite.
 
3:44 PM
But the base types are still finite.
 
I'd also argue the reverse direction: enums are a special case of ADT (namely that of all members being parameter-less).
 
But then I don't see how Option<T> being immutable is a problem if you just want to have some "generic" T|null
@Crell Well yes and no, ADTs are sum and product types
 
@Girgias Immutable types are simultaneously less efficient and less ergonomic in general than value-types. At least that's my experience.
 
And sure for a computer int is finite, but that's still a lot of values, strings are effectively infinite
@LeviMorrison I care about semantics and correctness first, then ergonomics and efficiency :p
 
Value type mutation: you get a new object if you don't have sole possession of the original one.
Immutable "mutation": you always get a new object, even if you have sole possession.
These are just as correct as the other, yes?
 
3:49 PM
@LeviMorrison IME, that depends on your architecture. I built Serde on 99% immutable values. The only things that aren't are arrays.
(I reiterate: readonly was a mistake. It is broken. We should not have done it.)
 
@LeviMorrison That's only valid when passing it to a function
There are no "by-value" semantics in a local scope
anyway need to go to sleep it's 1AM here
 
Okay, that's true. I'm not sure that it matters in a significant degree. In fact, I know I've seen videos of the haskell type people advocating that local mutability is great...
 
IMHO that's a thing for a compiler to care about, if the value is only ever modified and the original never accessed again, then sure feel free to mutate the initial memory layout
Yes functional programming with pure functions and immutable values all the way is a PITA in some regards, but it brings some nice benefits. It's just dealing with the fuzzyness at the edges that is where this stuff suffers
Also you can more or less write "traditional" OO objects in functional programming languages
 
4:17 PM
@Girgias Are you still on vacation somewhere? Because it's not 1am in the UK... :-)
 
@Crell In Japan with my parents
Currently in Hiroshima :)
 
Have fun!
 
 
1 hour later…
5:45 PM
@LeviMorrison But, Rust also can't really do that, right? Option::replace is implemented using mem::replace, apparently. You cannot replace a single associated value.
To be fair, we don't even have something like mem::replace. I don't necessarily object to making enums value types and modifying them. I just don't know what that would look like.
 
 
1 hour later…
7:07 PM
Then we'd need a way to flag enums as immutable or mutable, because we will certainly want immutable enums.
 
7:30 PM
@Crell Not sure, why? Do we need immutable arrays?
Essentially,.with value types,.mutating just becomes a shortcut to clone, modify the given field, and replace the entire value.
 
7:58 PM
@IluTov Can you give an example for "replace a single associated value"?
 
8:13 PM
@LeviMorrison Isn't that what you are suggesting? You're suggesting that it should be possible to replace $value in Option::Some. But Rust doesn't allow that normally, for enums. Option::replace is a bit of a "hack", to replace the entire enum in-place. At least that's my impression. Something like $option->value = 42 is fine, but it's a bit irky because technically you're supposed to access (and by extension write) associated values through pattern matching.
 
@IluTov It replaces the whole enum, not just the $value. None.replace(4) is perfectly fine.
 
@LeviMorrison Right. So that's what you're asking for? That the mutating method can replace the entire enum?
$this = Option::Some(42) is not unreasonable. I think Swift uses the same syntax.
 
8:55 PM
Logically, you can't work with sub-types or whatever you want to call the discriminants in the enum. You can't do fn (Option::Some $opt) in most languages, just fn (Option $opt) which should clue people in that the idea of implementing these as distinct classes is not really a good idea. You have an Option, and you can replace that option with a different discriminant, and that's fine.
But if we use PHP objects, that doesn't work. You can't replace the "same" object with an object of a different type.
I haven't really thought about $this = Option::Some(42);. If we have value types, maybe that does make sense to allow. But at the very least, $opt->replace($value) where $opt is either a None or a Some should be possible.
Using the container analogy again, $opt->replace($val) is basically $container[0] = $val, and $opt->take() is basically $container->pop().
 
@LeviMorrison I'm confused what you mean here.
@LeviMorrison Do you mean replace as a generic construct? Or something specifically for Option? If $this = Option::Some(42) was possible, any enum could implement such modifying methods. Although, thinking about it, this might also be complicated. E.g. $old = $this; $this = Option::Some(42); return $old;. I realize the function would normally return the value, and not the whole previous enum, but this code still looks like it should work. But separating $this is impossible, without loosing the reference to the object originally referenced from the call-site.
I.e., we cannot just modify EX(This), as that won't actually change the referenced object. We'd need to modify the object it points to. But it would need to be separated, so that $old isn't also modified. However, separating it detaches it from the call-site, e.g. $option->replace!(42).
 
10:11 PM
@IluTov As long as you would implictly ref-fetch the object (fetch_w, make_ref, call) if the method assigns directly to $this, this would work.
I mean, in rust it's literally &mut self. I.e. a call with $this taken by ref.
 
10:36 PM
I'll have to think more about this case. It occurs even without $this = .
 
11:08 PM
@IluTov Yes, it also occurs when you explicitly take $this by ref (via a function call) … and … you cannot determine that statically because by-ref is callee dependent (sigh)
 
@bwoebi Not sure I follow. I was referring to $this->prop = 42 also needing to separate $this if $this is referenced in some other new local variable (after call-site has already separated).
 
@IluTov Ah I see what you mean
technically that can be solved by forced duplication when $this is directly copied. (i.e. avoid the CoW copy)
 
11:33 PM
@bwoebi I thought of this as well. Will have to check, especially whether this can escape through other ways.
 
@IluTov Given that $this cannot be taken by ref, no.
 

« first day (4909 days earlier)      last day (46 days later) »