« first day (3844 days earlier)      last day (1089 days later) » 
01:00 - 20:0020:00 - 00:00

1:49 AM
Folks, I have a BIG string that I write to it until memory is 80% used, point at which I process the string and clear the memory allocation.
Somehow, however, when trying to concatenate a small string into this big string, memory blows up - which indicates it uses more than the 20% of memory I had reserved
Essentially: $this->query .= $value;
Is there a more memory-efficient way of appending data to the end of a string in PHP?
I guess I will use arrays and implode when I need the string
even though, I can't implode if all my memory is allocated to what I'm imploding
I'd need to use array_pop
I guess I'll use an SplQueue
 
2:20 AM
I think I got it.
$this->query[] = $value; // until memory almost full
$this->query = implode('', $this->query);
 
it doesn't matter if you are using concat ., .= or implode, they all need to allocate memory for the result while the arguments are still in memory, hence if your arguments are already filling up more than 50% of the memory (and due to fragmentation, in general even less) you will run out of memory since there is no memory left for the result
 
2:40 AM
Yeah, still memory issues. So essentially I can't append to a big string without temporarily doubling the memory allocation of that string while PHP resolves the concatenation?
 
ye, there might be workarounds to do something similar, f.e. write your strings to a (tmp)file and load everything as single string
 
 
2 hours later…
4:38 AM
\o
 
4:56 AM
@NikiC is this right ?
 
5:22 AM
@beberlei can you look at that too ?
I can't figure out why those calls look different, they are the same only the second one uses named arguments and behaves strangely ... maybe that's intentional ? am I missing something ?
 
 
1 hour later…
6:33 AM
morning \o
 
6:52 AM
\o
 
everyone seems to be on the side of attribute on the sealed classes RFC discussion
 
7:08 AM
I still don't think attributes should be part of the type system ...
it's strange, it's about as strange as type system in docblocks, and we spent years moving away from that ...
 
the difference is that docblocks weren't being verified by the runtime
 
but nor are attributes, they are a fancy docblock, not integrated with the type system ...
nobody would ever have suggested making docblocks part of the type system formally, and we shouldn't do that for attributes
 
personally, i'm okay with either, keywords looks nicer, but as long as it's verified by the runtime, and has a defined behavior, it's fine \o.o/
 
I disagree, strongly ...
the majority aren't always right ... asking a bunch of people who have never designed or been involved in the design of a type system how to extend a type system doesn't make sense ...
I'd much rather listen to the thoughts of one or two people who I consider expert, like dmitry and nikita, than ask a bunch of people that honestly haven't got a clue ...
votes and majorities and democratic process are useful to us, but they can also be harmful ... for example, you hold a vote to ask the people of a country if that country should have a nuclear arsenal of weapons ... what you don't do is ask them how to design the weapons ...
because everyone will die
 
I think if PHP had some sort of a hook for attributes, it would make much more sense, and sealed classes can even be implemented in userland using attributes right now.

e.g: i create `Sealed` attribute, i register a hook for said attribute, and whenever PHP engine encounters a class that uses it, the hook callback is triggered.

^ this however will unleash hell probably
@JoeWatkins I agree, but no one seems to want a new syntax :/ will leave it as is for now, and see later.
 
7:36 AM
@SaifEddinGmati It is unfortunately a big problem with the mailing list that you have feedback from a few louder peoole, but you can't know the opinion of the majority before starting the vote.
For example I would prefer a new syntax much more than an attribute. Although I have to admit that I have not much interest in sealed classes
And I agree with Joe that there are a few people whose opinion matters much more than anyone's else. Unfortunately Dmitry admittedly hardly ever reads internals
 
8:27 AM
@JoeWatkins yes, func_get_args doesn't support named params
 
I see
 
@JoeWatkins Sorry, I got confused by the other stuff. The variadic parameter is not "targetable" as a named parameter
It always collects whatever is left over
Otherwise it would basically be impossible to do parameter passthru, as you could never pass thru whatever you named your variadic parameter
 
yeah I think I'm getting it, this is the first time I've looked real close at named params ... I might need you to read over some code and point where I got wrong, but I'll have another couple of tries at it first ...
thanks for explain
 
9:07 AM
@beberlei 3v4l.org/Ss8uk
classes don't inherit attributes ...
seems wrong to me ...
 
9:46 AM
Morning o/
 
Morning :-)
 
Catching up on the chat - I can certainly see a benefit in using attributes to change behaviour. But I do think we need a mechanism to signify the version they're targeting, as in the absence of a keyword which would cause a compile error, an attribute could be ignored, allowing unexpected behaviour to pass through that on later versions would be prevented
 
 
1 hour later…
11:00 AM
@JoeWatkins Same for methods: 3v4l.org/KDCvX seems right to me.
 
@SaifEddinGmati Btw, I don't agree that sealed should be an attribute. Attributes are great for userland, but since all other things right now are modifiers, why here?
Also, it might be worth looking into what other languages do. A lot of languages have a sealed modifier but I'm not aware of any that have a sealed attribute.
Something else also worth considering: Many languages do sealed by nesting the classes instead of listing them in the sealed class. That does pose some issues for autoloading. But I think the syntax would be a lot nicer.
On the other hand, that makes it even more similar to enums.
 
@kelunik class Bar extends Foo, if Foo has attributes, so must Bar have the attributes ... or else the attributes are nothing to do with Foo ...
same for a method, if you re-implement a method in Bar from Foo, and the method from Foo has attributes, so must the Bar method have the same attributes, or else ...
attributes aren't really useful for extensions, at all, if they don't inherit properly ...
there's supposed to be an internal attribute validator, and it's not useful right now because inheritance is not done ...
 
@JoeWatkins I agree it's unexpected. I haven't followed the discussion. One benefit of not inheriting attributes could be that it would make removing attributes in overridden classes harder. That's probably more of an edge case, and that could still be achieved with an attribute like #[ClearAttributes].
 
diff --git a/Zend/tests/attributes/011_inheritance.phpt b/Zend/tests/attributes/011_inheritance.phpt
index 6a589b9253..e3fe35f8a4 100644
--- a/Zend/tests/attributes/011_inheritance.phpt
+++ b/Zend/tests/attributes/011_inheritance.phpt
@@ -12,12 +12,12 @@ class C1

 class C2 extends C1
 {
+    #[A3]
     public function foo() { }
 }

 class C3 extends C1
 {
-    #[A1]
     public function bar() { }
 }

@@ -74,12 +74,16 @@ Array
 )
 Array
 (
+    [0] => A2
 )
 Array
 (
+    [0] => A3
+    [1] => A1
here's a starting place ...
 
Docblock uses @inheritDoc. But I think that it inherits everything by default if a docblock isn't used
 
11:12 AM
I'm not going to finish if people don't agree that this is wrong ... I don't really care, they're just not useful to extensions the way they are ... the first time I try to do something useful with them and they are essentially broken/unfinished ...
they are most certainly not useful for extension of the type system, not at all ...
 
@MarkR Although all static analysers now inherit by default, even without @inheritdoc.
 
@MarkR That is what the spec says yea
 
@JoeWatkins Was this discussed at all? Searching on wiki.php.net/rfc/attributes_v2 for "inherit" gives no results.
 
I wasn't paying attention at the time properly, I don't know ...
 
@JoeWatkins externals.io/message/108907#108961 Looks like Benjamin explicitly decided against inheritance but sadly it wasn't mentioned in the RFC itself.
The difficulty might've been in merging attributes from parent classes and interfaces. Or removing specific inherited attributes as mentioned above. Changing it at this point will definitely require an RFC.
 
11:19 AM
well that's what they are then, fancy doc blocks, as useful for extensions or modifying behaviour of the engine as docblocks were ... utterly pointless ...
 
11:35 AM
@JoeWatkins Inheritance of attributes opens a can of worms.
If you want to extend the type system with them, here's an example from Java: parent has @Nullable, child has @Nonnull, inheritance would give the child both attributes.
It might make sense to inherit some attributes, but as they're only loaded at a later point, PHP can't make inheritance an attribute of an attribute.
What works is moving inheritance rules to the attribute resolver / reader, it can decide whether to look in parent classes or not for a specific attribute.
 
That wouldn't allow its use for engine behaviour though
 
That's not true. The engine can make the same decisions.
 
@kelunik I definitely don't want to extend the type system with them, but you can tell by reading the sealed classes discussion that everybody expects them to be capable of this, and they just aren't
I seem to remember them being sold as useful for extension to effect behaviour, and effecting behaviour without new syntax ... they can't actually do any of that in the real world though ...
I don't see this can of worms, if a class declares an attribute and the child class does not, it should be inherited, if the child class declared the same attribute, it doesn't need to be inherited from the parent ...
 
I seem to remember discussion came up about when to bind attributes, and it was passed with resolve on read. Were this not the case, things such as inheritance rules could be an attribute of the attribute itself, much like its repeat usage and location rules are
 
11:54 AM
@JoeWatkins if you implement two interfaces with conflicting attributes?
If you want to remove one attribute, how do you do that?
@JoeWatkins reading it, I don't see an issue with using an attribute there
Apart from attributes defining behavior that silently isn't present in older versions.
 
using an attribute is no different to using a docblock, if attributes behave like docblocks ...
you surely wouldn't entertain that ... there's no difference ...
 
12:15 PM
It's worth noting that as fancy docblocks they're very useful
 
@kelunik I'm not sure that interfaces should have attributes ... what does an attribute on an interface even mean given that they are not currently inherited anyway ...
they probably shouldn't have them, same as they don't have properties ...
 
I guess it depends on the meaning of the Attribute. I could see an interface having a #[Deprecated] attribute. I have a project where I put an Attribute on an interface to signify that it should be shared in a dependency injection container.
 
I use attributes on interfaces to specify which their default concrete implementation is for my DI container
 
@JoeWatkins They can be quite useful, e.g. for code generation based on an interface.
 
FWIW though I agree that sealed should not be an Attribute. Personally am ok with PHP releasing very few/no attributes and letting userland deal with them. I love the idea of sealed types though.
 
 
2 hours later…
2:15 PM
@IluTov hacklang is the only using attributes ( docs.hhvm.com/hack/attributes/predefined-attributes#__sealed )
@IluTov that's tagged enums :p
 
3:13 PM
update on the RFC: #[Sealed(...)] syntax choice has been removed.
 
\o/
I've wanted sealed-like behavior for a while now so I hope your RFC gets accepted
 
3:55 PM
@SaifEddinGmati I'm quite open to sealed classes. :-) As I said last night on the list, I really do want the functionality, one way or another. We just have multiple routes to it.
... why did Olle respond to my email several different times?
 
@NikiC I was going to push a commit to add a test for some missing coverage, should I remove your commit first?
 
@JoeWatkins that is expected wirh inheritance
 
@SaifEddinGmati Possible other syntax idea: final class Foo permits Bar, Baz ? (Since a sealed class that has no for/allows/permits list is effectively the same as final.)
 
@Crell seems like different arguments but sent separately ..
 
@SaifEddinGmati Yes, but... why? He sent a different email for every paragraph he was responding to.
 
4:09 PM
@Crell IMO, a sealed class with no permits should be a syntax error.
@Crell 🤷‍♂️
 
Possibly. But it's effectively the same result as final; or, conversely, sealed classes are final with holes in it. So why not unify the syntax?
 
because i think final should still mean the same thing "inheritance ends here", while sealed is "inheritance might continue, but only for ..."
 
Valid, but then you're drawing a harder distinction between inheritance cardinality of 0 and of 1 than I think is really necessary. Especially if minimizing new keywords is a goal (as it usually is).
 
4:24 PM
> if minimizing new keywords is a goal (as it usually is).

for me, it's not a goal, you can post `final class Foo permits Bar, Baz {}` syntax in internals, if other people are interested in it, i might add it as an alternative syntax, but personally i don't like it.
 
minimizing new keywords is a sensible goal if they can't be isolated to one context in the grammar; e.g. if you would no longer be able to have a class called "sealed"
 
Attributes is a better fit for a sealed class IMO. If we were adding final today, maybe it would be an attribute.
 
IMHO, it's either all or nothing, someone can open an RFC later to move final, abstract, and sealed ( if accepted ) to attributes
 
they're not a fit for anything, they can't do anything, they're not finished or not implemented in the way you think they are ... it can't actually work ...
 
@JoeWatkins No? So at runtime it's not easy to look if a class has attribute X?
 
4:32 PM
e.g:

```
#[Sealed(User::class, Organization::class), UniqueEntity(fields: ['handle'])]
abstract class Account
{
...
}
```

is extremely weird. `abstract` changes how class can be used, and so does `Sealed()` but one is a modifier, and the other is an attribute, while `UniqueEntity` really has nothing to do with how the class is used or inherited.
 
they're as good a fit as docblocks, they behave like docblocks ... uselss for extending the type system, or anything else, just like doc blocks
 
When attributes passed there was much discussion of potential internals uses for them in the future. The necessary hooks for that may not have been added yet, but that doesn't mean they couldn't be.
There's definitely interest in doing so.
 
there is already one internal attribute: #[Attribute]
 
@IMSoP let's keep it that way :p
 
I've no particular opinion on the current case, but I see no particular reason attributes couldn't trigger behaviour
the #[Deprecated] proposal seems reasonable
 
4:36 PM
#[Sealed(Bar::class)]
class Foo {}

class Bar extends Foo {}
 
IMHO, attributes are amazing to replace annotations ( e.g: @Entity(), @Assert\Length(min=4), @UniqueEntity(), @ApiResource ... etc ), and should be used for stuff like that
 
I think "stuff like that" is not well-defined
 
when sealed is an internal attribute, you expect that it's validator will be triggered when Bar is created as a class, but that's not the case, because the attribute is not inherited
 
why does that require the attribute to be inherited?
 
@JoeWatkins actually, in this case, it should not be inherited. because Bar should be open for inheritance
unless it is declared final or is sealed itself
 
4:39 PM
There's a host of assertion-type behavior that would make a ton of sense to put into the engine. Or at least the hooks for it.
 
@IMSoP there is no relationship between the sealed attribute and Bar
 
I don't get why that's any different from the "final" keyword
 
these are the hooks that attributes have today, that's how it actually works today
we should stop suggesting we use them for things they cannot actually be used for until the implementation is improved
 
when "extends Foo" is processed, the class Foo has to exist, and information about it is checked, including whether it's marked final
 
@JoeWatkins I don't expect the implementation will be improved until there is a use case on the table that requires it.
 
4:41 PM
why is it any different checking what attributes are against Foo at the same time?
 
@IMSoP these are the hooks that attributes have today, that's how it actually works today
 
what are? I don't understand the problem
the attribute is against Foo, as is the "final" flag
are you saying that there's no internal API for checking attributes on a class at all?
 
#[Sealed(Bar::class)]
class Foo {}
there's a hook for that, an internal validator
but you get no notification that Bar has been created because it does not know about the attribute, it's not inherited, never executed in relation to Bar with respect to the attribute you think it's inheriting ...
 
... WTH, Olle?
 
@JoeWatkins I don't get why anything needs to be "notified"; wouldn't you just write the equivalent of "if ( class_has_attribute($parent, 'Sealed') )` ?
i.e. look up the attributes on parent_ce here: heap.space/xref/php-src/Zend/zend_inheritance.c?r=6cd0b48c#1263
 
4:48 PM
where do you want to write that ?
 
exactly the same place you'd write it if it was checking against a keyword
 
the point is that it cannot be implemented as an attribute, it must be implemented as a modification to the type system because attributes can't support what we want to do on their own ... if we're modifying the type system then the argument to use attribute evaporates
 
I think I'm not getting what "implemented as an attribute" means to you
 
on their own, attributes can't do this, or any other kind of modification to the type system, in a sense, they are not related to types right now, but lines in files, like docblocks ...
 
in my mind, if final classes were declared with #[Final], then instead of if (parent_ce->ce_flags & ZEND_ACC_FINAL) that line of code would read if (HAS_ATTRIBUTE(parent_ce, ZEND_ATTRIBUTE_FINAL)) and everything would proceed exactly the same way
I'm not sure if you're saying that's not possible, or just that it's not sensible
 
4:54 PM
>
the point is that it cannot be implemented as an attribute, it must be implemented as a modification to the type system
 
> I think I'm not getting what "implemented as an attribute" means to you
 
It really does sound like 2 different conversations are happening here... :-)
 
implemented as an attribute means could you implement it in an extension, as a pure attribute without modifying the type system ...
 
well, I wouldn't expect to, any more than I'd expect it to work with Symfony without modifying Symfony
something has to read the attribute, and do something with it
 
Sealed implementation in userland ( but have to call validate(Foo::class) after each declaration ) 3v4l.org/uFnp8
 
4:58 PM
"any more than I'd expect it to modify the behaviour of Symfony", that should say
it sounds like you're thinking of something more like AOP
 
attributes are supposed to be useful for this very thing, even though I think it's a bad fit, they're supposed to be able to do exactly this kind of thing ...
 
the RFC intro calls them "a form of structured, syntactic metadata"
not hooks, or injection points, just metadata, to be read by something else
 
like @Crell said, there was all kind of talk of being able to use them for internal stuff, and being able to use them to avoid adding new syntax ...
well they can't do those things
 
yes, they can
 
Can't ever, or can't yet? Two very different things.
 
5:03 PM
on their own, you still have to modify other parts of code
they cannot
 
"on their own" is meaningless
the implementation has to exist somewhere
 
can't PHP trigger the same kind of validation as in 3v4l.org/uFnp8 after the class is loaded?
 
the RFC gives this example C code:
static int zend_needs_manual_jit(const zend_op_array *op_array)
   return op_array->attributes &&
        zend_hash_str_exists(op_array->attributes, "opcache\\jit", sizeof("opcache\\jit")-1));
}
that's not "triggering an event", it's the opcache instruction actively looking for the attribute, and changing behaviour based on it
and yet, it means that we don't need a "Jit" keyword
"opcache extension", not "opcache instruction", sorry
 
this IMHO, doesn't change how the code is executed, or how inheritance work, unlike "final", "abstract" or "sealed".

OPCache\JIT() makes sense as an attribute, but not the others.

however, if we would use attributes for these, it's better to switch everything at once rather than introducing more inconsistency in PHP.
 
oh, I definitely get the consistency argument
 
5:08 PM
/* seal extension for PHP */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "php.h"
#include "ext/standard/info.h"
#include "php_seal.h"
#include "seal_arginfo.h"

#include <zend_attributes.h>

zend_class_entry *zend_ce_seal;
zend_internal_attribute *zend_attribute_seal;

static void zend_validate_seal(zend_attribute *attribute, uint32_t flags, void *scope) {
    if (flags & ZEND_ATTRIBUTE_TARGET_CLASS) {

        zend_class_entry *ce =
            (zend_class_entry*) scope;

        if (ce && ce->parent) {
that would be all that is required to implement sealing (with more work in validate_seal), that is what I mean by "on their own" ...
they cannot do this right now ...
are we going to special case every internal attribute in the type system ? also you must be able to see how their usefulness to extensions is extremely diminished if they can't implement modifications to the type system on their own ...
 
again, that looks like AOP, not Attributes
both can be used for this problem
as you say, without a hook system, extensions can't make arbitrary changes to the type system; but even with a hook system, they can only make changes that there are hooks for
 
what looks like AOP ? attributes that get inherited look like AOP ?
 
attributes that trigger a callback function
 
that's how internal attributes do work ...
all that is required for that implementation to actually work, is that attributes are inherited ... and they're not ...
 
as well as inheriting the attribute, you'd need a way to know that the attribute has been inherited, otherwise the user would have to whitelist the parent class to inherit from itself
at which point, you've basically got a "run this on inheritance" callback
I think what most people mean by using attributes internally is exactly what they mean by using them in userland: having code that checks for certain attributes, and performs behaviour based on them
 
5:19 PM
@Trowski yeah
 
@JoeWatkins so fully back from 5 hours in the car with a fuller response. other languages have an option on their #[Attribute] equivalent where you can switch from no inheritance to inheritance. see stackoverflow.com/a/23973331/1346233 - @Inherited, we could do that with #[Attribute(Attribute::INHERITED)] - but it was out of scope for the original RFC
@JoeWatkins AOP for attributes requires the callback to be called when a method/function is called or propery is written to. the callback for attributes is currently called for validation the attribute only once
 
what's the intended use case for the validation callback? is it just to tell whether the attribute itself is valid, e.g. has the right arguments passed to it etc?
or was it intended that actual behaviour could be included in that callback, affecting the target of the attribute?
 
@beberlei I'm not confused about what AOP is, I was confused about what @IMSoP thought "looked like AOP" ...
 
ah :)
 
Even if not used for sealed, adding flags for inheritable and final to attribute seems like a good move.
Tangentially related, @NikiC Do you intend to bring new in initializers to vote during this cycle? I'm really looking forward to the extra power they'll bring to attributes.
 
5:38 PM
the name "validator" suggests to me that the callback there isn't intended for any kind of behaviour, it's just for saying whether the attribute itself has been specified correctly
e.g. you might want to raise an error on #Sealed(42) because "42" isn't a valid class name
 
5:49 PM
@beberlei I'm disappointed that it was implemented with this strange default behaviour, they really are about as useful as docblocks right now, the only difference is they're parsed ... when the guy that implemented attributes suggests that we should use them for some thing, everyone assumes it's because they can be used for that thing ...
 
@JoeWatkins sorry :(
 
@JoeWatkins I think you just have a different understanding of "used for"; in userland, they can be "used for" autowiring, and route declarations, etc; in the engine, they can be "used for" things in exactly the same way
what they can't be used for, in userland or the engine, is hooking arbitrary compilation or execution points without modifying code to check for them
 
but they can't be used for things such as "Sealed()" as validation needs to happen when the class using a sealed class is loaded.

surprisingly, it's easier to implement sealed using attributes in user land ( https://t.co/u3gsMM15dh + hijacking composer autoloader to trigger validation when a class is loaded )
 
@SaifEddinGmati sure they can; you can check for the presence of an attribute in exactly the same place you'd check for the presence of a custom flag on the C struct
instead of checking for something like parent_ce->ce_flags & ZEND_ACC_SEALED, you'd check for something like parent_ce->attributes && zend_hash_str_exists(parent_ce->attributes, "sealed", sizeof("sealed")-1));
 
there is no reason why not having the attribute during compiling would set a ce_flags & ZEND_ACC_SEALED
 
6:00 PM
ZEND_ACC_SEALED is what I'm imagining it would be if you didn't use attributes
 
see this zend_compile_func_decl way for #[Deprecated] github.com/php/php-src/pull/6521/…
 
oh, I see what you mean, so the attribute check would set the internal flag; yeah, that could work too
 
please, don't suggest that we start special casing internal attributes in the type system
either attributes are useful for making this kind of change, or we have to modify the type system
 
sealed has nothing to do with the type system imho
 
your opinion is wrong, the code you modify to implement sealing is part of the type system
 
6:05 PM
I wonder how something like sealed attributes would interact with reflection. Would it be available directly or would one have to go and look at the attributes.
 
@beberlei it does, sealing allows you to control the possible sub-types of a specific type. that's enough in my opinion to consider it part of the type system.
just like final declares that a specific type cannot have any other subtypes to it.
 
@JoeWatkins those two things aren't mutually exclusive; attributes can be useful for part of the job, even if they require code for other parts of the job
they mean no new syntax needs to be reserved or parsed, for a start
whether that's a good enough reason in this case is a different question
but they can be used that way, and using them that way internally has exactly the same advantages that using them in userland has
and the amount of docblock annotations that got used in userland showed just how much advantage people saw in having those
 
@IMSoP they are
 
just to be clear, "like docblock annotations but parsed natively" is exactly what the RFC describes them as
 
final does make it more consistent to have another keyword for sealed, but in general with attributes the the language itself could be simpler and use this generic hook
less code in the parser, compiler, etc..
 
6:14 PM
@MarkR interesting question; if we imagine a world where "final", "abstract", etc were attributes, maybe we wouldn't bother with separate methods in reflection to expose them
 
@JoeWatkins you are right it is part of the typesystem, but more a modifier than about types
 
@IMSoP fine, that's how they should be treated ... don't suggest using attributes for anything you wouldn't suggest or wouldn't have suggested using docblocks for ... if anyone suggested using docblocks to implement type system changes before attributes existed it would be rejected, and we should reject using attributes today for exactly the same reasons ...
@beberlei this is just one narrow case, attributes are meant to be useful for extensions, meant to be able to allow extensions to implement things that would otherwise require new syntax, that was a big selling point ... and it does not work ...
 
@JoeWatkins why does it not work?
 
and can't work, you still end up having to make internal changes, which is fine if we're talking about an internal feature, other than the mixing of the type system and attributes ... but totally impossible from an extension ...
 
We would benefit from trying to pre-empt additional features where attributes may provide an improved experience vs additional keywords. Something in the same vein as sealed, would be friend classes able to access each others protected methods and properties.
 
6:21 PM
the #[deprecated] patch would be be posible with an extension and creative ways of combining hooks imho
 
@beberlei you can't even implement this one narrow case
@beberlei what happens when you extend a deprecated class ? what happens when you implement a deprecated method in a child ?
does it really work ?
it doesn't really work, you'll have to modify the type system to make it work consistently, and in a non-surprising way ...
 
attributes are not hooks, they're just syntax; @ORM\Entity(repositoryClass=ProductRepository::class) doesn't hook Doctrine, it's syntax that Doctrine reads and does something with
but within the implementation, that defines a relationship between two classes
there's no reason an extension can't behave exactly the same way: look at the attributes on something, and decide what to do with them
 
php has no such things as deprecated classes at the monent, and with extending deprecated methods it would depend on the behavior of ZEND_ACC_DEPRECATED, i would assume it inherits the flag
adding Attributes::INHERITED behavior is trivial, it just wasn't done in the original patch
 
okay I read the patch
> deprecated = zend_get_attribute_str(op_array->attributes, "deprecated", sizeof("deprecated")-1);
nope
 
why?
 
6:32 PM
I don't want to special case internal attributes, what about in 10 years when there might be 10 or more such statements ? I don't want to go down this path not even one step ...
 
how is it different from special-casing a keyword in the parser?
 
its not that different from this kind of code github.com/php/php-src/blob/master/Zend/zend_compile.c#L6920-
 
meh I give up ... this is going to make a mess ...
 
personally i removed the attribute syntax from the RFC, if someone wants to change it later and use attributes, they can open an RFC to do so if this one got accepted.
 
well we could think about calling a hook there or making it an api on zend_attribute in a way that the compiler does not need to change
 
6:41 PM
either they are like docblocks, and should be treated as such, or improve them so they're not like docblocks, and then we can seriously entertain future uses ... the current path leads to madeness ...
but it doesn't matter, if you put it to a vote, people will use their feelings, instead of knowledge and their brains to vote it in based on how it looks or seems to them ...
this is all sorta broken ...
 
feelings > facts
 
will it break anything if these variable names are improved? github.com/php/doc-base/blob/…
 
@JoeWatkins I believe the attribute option was removed from the RFC
 
@JoeWatkins So what would a more generic "attribute hooks that impact the engine" API/patch look like? Honest question.
 
$d1, $d2... $h1, $h2, $s1, $s2 and so forth...
 
6:44 PM
kinda like the patch I already wrote a few hours ago, that would allow you to implement sealed from extension which I also wrote a few hours ago ... it wouldn't have to look like that, I don't care ... but you can't say they are like docblocks and then use them for type system changes, that's obviously as fucking crazy as using docblocks ...
 
@Tiffany they are inside a function, so probably not.
 
@JoeWatkins please don't give up, trying to honestly get into your side
 
@beberlei It would be better if a handler could be triggered when an attribute is added to the op array.
 
@Trowski yes, and the same would be necessary for zend_class_entry, zend_property and such
 
@Trowski that would still not cover the sealed attribute use case.
 
6:52 PM
@beberlei Right, attributes could have handlers for each.
 
right now there are no internal attributes, and I don't believe they are going to be widely used by extensions, so could we not just change the default for internal attributes, in the case of classes and traits only, to inherit by default ?
 
"Can't say they are like docblocks and then use them for type system changes." - Um. I don't know who was saying they're just like docblocks, but they're wrong. :-) Attributes get parsed by the lexer, docblocks don't. Attributes tie into reflection, docblocks don't. Attributes eliminate the need to implement hacked up pseudo-attributes in docblocks, but that's it.
I don't have a strong feeling either way about attribute inheritance at this point.
 
@SaifEddinGmati What about final permits (OtherClass) class ClassName? I think you can do that without reserving permits.
 
@Tiffany Are you hype for AmongPHP today?
 
@Trowski @Crell already suggested final class ClassName permits OtherClass {}
 
6:59 PM
That I think requires permits to be a reserved word.
 
@Crell with regard to types, they are actually like docblocks - they are not carried with type information, they are relative to a file and line right now, like a docblock, regardless of how they are parsed ...
 
I'm late to the conversation, what does "permits" imply? That class can extend this one?
 
@JoeWatkins i believe if we add a flag on attributes that allow inheritance, then an intenral attribute can just set that flag when it needs it
 
ELI5 what problem this is actually trying to solve?
Like... so what if someone extends a class you didn't want them to extend?
 
7:03 PM
@Sara See my reply here: externals.io/message/114116#114142
It's an alternate route to get to ADT/tagged union like behavior.
 
you want me to do it, or are you gonna do it ?
 
(I want you to give me the green light on partials before you start on anything else new and shiny. :-) )
 
@JoeWatkins i'd like to if you don't mind
 
@beberlei that's cool, just offering :)
 
@beberlei why internal? i believe this could be useful in userland as well ( as you mentioned before using #[Attribute(Attribute::IS_INHERITED)] )
 
7:06 PM
@SaifEddinGmati one step at a time :D exposing hooks to userland is another beast
 
"""Now if you have an instance of Maybe, you can be absolutely guaranteed that it's either an instance of Some or of None.""" <--- That sentence got my attention.
 
@Crell there are some inconsistencies with combined variadics and named parameters, nothing that is not in principle solvable, but it's good enough to go ... it's likely I'll solve those problems and then nikita or dmitry will tell me how to do it better anyway ...
 
@JoeWatkins Excellent. I'll put the RFC out to the list now then. Thanks!
 
@Sara yesss
 
However, would type aliasing and package visibility solve that just as easily?

private class IMaybe { ... }
class Some extends IMaybe { ... }
class None extends IMaybe { .... }
type Maybe = Some|None;
 
7:08 PM
I liked that post to internals also, I hadn't thought about any of that ...
 
@Tiffany Woot! I'm hype too!
 
@Sara Package visibility sounds harder than either tagged unions or sealed classes. :-)
And type aliasing has interesting autoload-related challenges.
 
yes, but less guarantee, and users can easily work around it.

if that's defined in the global scope, then anyone can just implement IMaybe, if it's in another namespace, people can still easily declare symbols in that namespace, and get around it, so at the end, there's 0 guarantee that there's no other 'IMaybe' implementations
 
@Crell Possibly, but I think both have wider applicable usages.
 
package visibility requires figuring out what a "package" is
 
7:10 PM
I have some thoughts there that are well beyond my ability to implement... :-)
 
one big problem with package visibility is that namespaces - the only thing we have analogous to a package - don't really exist ...
 
"""if that's defined in the global scope, then anyone can just implement IMaybe""" No. That's what the private is there for. It makes it file-local visibility (or would if we had such a thing).
 
@IMSoP my statement assumes a package is a namespace
 
I think package could be namespace (protected) or file (private)
 
@SaifEddinGmati that doesn't really fit with how namespaces are used in practice
 
7:12 PM
ugh, not a fan of declaring more than 1 thing in a file.

java sealed classes allows declaring classes sealed with no permits clause, and it would be permitted to only other symbols in the same file.
 
How about:

protected class Maybe {
friend class Some;
friend class None;
}

... okay, maybe I'm trying too hard to be C++
 
That multiple symbols in a file is problematic is a PHP-autoload-convention-specific issue. Few other languages give a crap.
 
@IMSoP it's the closest thing PHP has to a package 🤷‍♂️
 
@SaifEddinGmati right, which is why I said package visibility requires figuring out something new
actually, the closest thing PHP has in practice is a Composer package
the language just doesn't know about them
 
In any event, if Some and None aren't in the same file as Maybe, then nothing stops the user from making sure their implementation is loaded before the "official" one.
 
7:14 PM
@Sara not if my library ships it's own loader muhuhuh github.com/azjezz/psl/blob/1.7.x/src/Psl/Internal/Loader.php
 
@SaifEddinGmati Sorry, I'm physically incapable of seeing past your use of unescaped backslashes in your single-quoted strings.
But also, no. An application could manually load their implementation, bypassing autoloading altogether.
 
I still have this feeling that autoloading should be replaced with package-based pre-loading
the compiler and opcache would then be able to see whole class trees at once
 
using that, everything can be replaced, interfaces can be modified, final can become non final, abstract can become non abstract, a trait can become a class, and a class can become a trait.

if someone is doing that, they can report bugs in their own issue tracker, because i won't look into it as a maintainer.
 
@SaifEddinGmati That also applies to people ignoring an unenforced #[Sealed] attribute ;)
 
@NikiC hence why it should be enforced :P
 
7:26 PM
SIGSEGV - core dumped on simple form submit ・ uploadprogress ・ #80979
 
this can be enforced by hijacking composer autoloader: 3v4l.org/Dek4H
 
@SaifEddinGmati I mean, the part about reporting bugs in their own issue tracker
 
@NikiC why would it be enforce ( p.s: #[Sealed()] syntax has been removed from the RFC )
 
/s/would/wouldn't/
@Crell final class Foo permits Bar {} for classes .. but what about interfaces and traits?
 
7:43 PM
Hm. Not sure there. Although I'm not as convinced of the use cases on those.
/me thinks he's done with the Internals list for today, for fear the spam filters will decide he's talking too much.
 
I personally think that every trait out there declare @internal could be declared sealed ( and therefor, another annotation down :) )
^ step closer to being able to write PHP without having to throw things in the docblock, but express them natively.
 
01:00 - 20:0020:00 - 00:00

« first day (3844 days earlier)      last day (1089 days later) »