« first day (4938 days earlier)      last day (10 days later) » 

8:47 AM
Where did the VLD output go on 3v4l.org?
Oh, I see. You have to choose "all supported versions" (for some reason)
Is it correct to say that this echo statement just allocates one string whereas this echo statement allocates 4 (via CONCAT)?
 
9:05 AM
I presume ROPE_ADD is just calculating the length rather than doing discrete allocations
 
 
3 hours later…
12:01 PM
Hey @azjezz happy to see you around. I'm in the same job hunting boat. I hope you find something soon.
 
12:32 PM
@QuolonelQuestions Yes. ROPE_INIT and ROPE_ADD are almost equivalent. They just push the string to a buffer that has enough elements for all the string parts. INIT is just an optimization that places the string at index 0 rather than looking it up dynamically. ROPE_END then loops through the buffer, counts the parts, allocates the string, and then places the parts in the right position.
 
1:06 PM
@IluTov Awesome. Thanks for the explanation :)
 
2:02 PM
who else is seeing notices about upgrading dokuwiki on php.net?
 
2:32 PM
Everyone
That's just "normal"
 
Everyone who has a login :)
 
 
1 hour later…
4:06 PM
I am in a talk about SPL at php[tek] :P
 
If it's about the Iterators that's fine
It's the only good part about it
 
There was a slide that listed what the talk would cover but I'm not able to find the slides quickly enough
 
OH NO NOT THE BAD DATA STRUCTURES
 
Depending on the vibe of the talk, because I like the speaker, I may ask about support for burning SPL to the ground
 
4:23 PM
Why would you need a talk for that? :P
 
There's now a section about iterators
 
4:37 PM
wiki.php.net/rfc/structs-v2 Let me know if you have any initial feedback. I'm unsure if I communicate the problem/solution well. It's hard to describe the solution without copy-on-write, but the RFC tries not to get ahead of itself.
 
@Girgias Well, most of the Iterators, anyway :D
 
@LeviMorrison True true :')
 
4:54 PM
@PeeHaa fair point
 
5:30 PM
@IluTov What happens if you put a mutating marker in an interface, and then you try to implement it on a class instead of a struct?
 
6:08 PM
@LeviMorrison Good question. I have not considered using interfaces for mutating methods. I guess they should be allowed on interfaces. But if a class tries to implement these methods, it'll throw.
 
6:27 PM
I think it may be possible to compile time error when mutating $this after all. We can detect all mutations to $this, except when $this is in some reference. In that case, we're not mutating $this directly, but the reference, so a separation is not necessary anyway.
 
6:42 PM
Or rather, we'll still separate the value in the reference, which is correct.
 
7:37 PM
Structs = Good. Structs with a better initializer syntax = better. Structs and classes with better initializer syntax = best
 
7:53 PM
@MarkR I think we still have curly brace syntax as an option. Think json except you write the object/struct name in the front of the opening {. Is that what you mean as a better initializer syntax?
 
@LeviMorrison Yeah, we have a lotttt of DTOs over in our code, it really helps keep things clean, but all it takes is for one bit of inheritance and then constructor promotion goes out the window because it's super tedious to have to accept them all in the parent, then copy them all back through into the child etc
I really like the TS/JS style of const foo = { key1: value, key2: value }, and especially like const foo2 = { ...foo, key1: value };
 
$foo = Foo { key1: $value1, $key2: $value2 };
$foo2 = Foo { key1: $value1, ...$foo };
I think as long as everything in Foo is public, it should be fine. I think the parser can deal with this.
 
Downside to $foo2 in that case is as we don't have an "undefined" it would overwrite key1 anyway
 
I think it would work more like Rust, where the values you give explicitly overwrite the ones applied by the spread operator.
 
In our codebase we have a single-case enum called Undefined::Undefined (because it can always be used with const expressions for initialization) and a few helper methods which do the same, but skip undefines, behaving more like array_merge
 
7:59 PM
In practice, this probably just does:
$foo2 = (clone)$foo;
$foo2->key1 = $value1;
 
Well in JS land the order matters, ...$foo coming first means any keys coming after it will overwrite values from $foo
 
I like the Rust way better but maybe that's because I like Rust a lot and have more experience with it.
 
@LeviMorrison Based on how PHP handles the spread operator with arrays, I'd expect key1 from $foo to overwrite the value provided.
 
I think treating them more like structs and less like generic maps makes more sense, personally, especially because it doesn't really make sense to chain them like you can with arrays. You can spread one map, not multiple.
// I don't think this makes sense.
$foo2 = Foo { ...$foo1, ...$foo0 };
 
I can think of several places right now in TS I do something similar (with the benefit of undefined) const foo = { ...globalDefaults, ...siteDefaults, ...overrides };
 
8:06 PM
@LeviMorrison You can spread multiple maps.
 
@Trowski Yes, but structs have important differences from maps.
Notably, that the set of keys is fixed. It doesn't make any sense to spread two structs into one structs, because the second will overwrite the first (if you allow these semantics, I mean). And that seems less useful than spreading a single one, and having your explicit keys take precedence over the spread ones.
 
That's due to the lack of undefined
Good ol Partial<T> <3 (I am partial to Tea)
 
Omit<T>
 
No :|
 
8:21 PM
Is this something which someone has tried implementing, or just hypothetical?
@MarkR My jab is invalid anyway, Omit requires two type args.
 
8:39 PM
@Trowski I'm 99% sure I implemented the parser at one point, just to make sure it was valid syntax. I didn't implement the whole thing.
If you always have a type name it was easy. If you support anonymous ones like maybe { foo: $a } is short for stdClass { foo: $a } then you have to deal with the fact that PHP allows {} as statements. IIRC it was doable but a little annoying. The fact that it's a statement and not an expression means it can work with backwards compatibility, as long as we're okay with the fact that you can't make a map literal that you never use, which seems fine.
function a($a) {
    // This is a parse error, although it's awfully close to
    // valid syntax of a pointless brace statement that
    // begins with a label.
    { foo: $a }
}
But if I remember correctly, the grammar was not pretty. It would have been nicer to move to a GLR parser, which I can't remember if we've done (I know several times Nikita did this to demonstrate a potential feature, but I cannot remember if any landed).
 
Seems unnecessary since PHP doesn't have unnamed objects.
 
Well, it'd make writing JSON easier :D
 
8:55 PM
Syntactically more similar to JS, not necessarily easier.
 
@MarkR Structs in most languages don't even support inheritance, so. :shrug: You can use composition rather than inheritance to avoid repeating all those properties.
 
function a($a) {
    // This is a parse error, although it's awfully close to
    // valid syntax of a pointless brace statement that
    // begins with a label.
    { foo: $a; }
             ^- this is semi-colon would make it valid
}
 
@LeviMorrison Is that what you would do for arrays? Or would you do $foo2 = $foo; $foo->key1 = $value1;? Because that's the approach the RFC chooses. The point is that you shouldn't think about copying for structs. The engine handles it for you.
 
@IluTov Well classes fully support it, and I'd be perfectly happy having an alternative way to initialize those too :-)
The only iffy thing I think would be properties not being able to be initialized with classes, other than that my feeling is that we'd probably never write another constructor again for DTOs if there as a better initializer syntax
 
@IluTov I'd use an explicit clone because of class objects. This would be fine also for struct objects, although yes, I would think you would usually just let the engine work it out for those.
Theoretically we could only do a clone if it's a class object, because then theoretically it could cannibalize the struct object being spread, but I'm not sure this optimization is terribly useful or worth spending time on.
 
9:16 PM
Does anyone know if something kind of like this exists already? Seems like working with array key/value data would have one turn up somewhere:
struct zend_key_value_pair_s {
        zval *key;
        zval *value;
};
typedef zend_key_value_pair_s zend_key_value_pair;
 
Nope
 
9:48 PM
@LeviMorrison There's Bucket which currently specifies a long key and a string key. But I don't believe there's something for arbitrary keys.
 
10:19 PM
Internally, if I'm calling the same function with the same args in a loop, do I need to copy in args every time? Or can I just leave it there? It's been too long since I've messed with fci/fcc stuff. Starting to forget the little details that aren't really documented.
 
@LeviMorrison I'm fairly certain you don't need to no
The FCI params should be copied when making the call
You'll need to dtor the retval tho
Also please don't use the crappy zend_fcall_info_* API
 
10:50 PM
If zend_call_function copies the args, and what dtors them? I don't see dtors in zend_call_function. Is it zend_vm_stack_free_args?
 
@LeviMorrison Pretty sure yes, as you are basically calling the VM to execute the userland function
 
$prefix/sapi/phpdbg/phpdbg_parser.y:58.21-28: warning: POSIX Yacc does not support string literals [-Wyacc]
   58 | %token T_OPCODE     "opcode"
      |                     ^~~~~~~~
I'm getting these with bison on Mac:
/opt/homebrew/opt/bison/bin/yacc --version
bison (GNU Bison) 3.8.2
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Haven't noticed them before.
 

« first day (4938 days earlier)      last day (10 days later) »