« first day (1466 days earlier)      last day (3473 days later) » 

10:08 PM
@rdlowrey yeah
 
Need some help here.
Why's this a shift-reduce conflict?
Oops, wrong paste...
variable_modifiers:
        T_VAR                                   { $$ = ZEND_ACC_PUBLIC; }
    |   non_empty_variable_modifiers            { $$ = $1; }
;

non_empty_variable_modifiers:
        variable_modifier                                   { $$ = $1; }
    |   non_empty_variable_modifiers variable_modifier      { $$ = zend_add_member_moidifer($1, $2); }
;

variable_modifier:
        T_READONLY                              { $$ = ZEND_ACC_READONLY; }
    |   member_modifier                         { $$ = $1; }
Why's this a shift-reduce conflict?
 
doesn't look like src to me
are you sure this is the cause?
i.e. you didn't do something like put T_READONLY in member_modifier as well?
 
10:28 PM
@NikiC I thought so, but nope.
Hmm
Let's try something...
Nope.
 
ah, I think I know what you're doing
 
@NikiC hmm?
 
Think about how the parser could distinguish public static $foo and public static function foo() if the public static part uses two different productions.
You changed it to not use the same production in both, so it doesn't know which to use
 
which two different productions?
there's only one way to get to T_STATIC
OH.
Oh I see...
Right, I guess I'll go back to making it a member modifier
@NikiC Fixed it by doing what I was doing before: Making it a member_modifier and then checking in Zend/zend_compile.c and erroring if you make a method readonly
Ooh, I've even got a nice error message to work, turns out that is possible! :D
$ sapi/cli/php -r 'class FooBar { readonly public $foo; public function __construct() { $this->foo = 7; var_dump($this->foo); } } $x = new FooBar; var_dump($x->foo); $y = &$x->foo;'
int(7)
int(7)

Fatal error: Cannot write to readonly public property FooBar::$foo in Command line code on line 1
Now, I know that's actually getting a reference, not writing directly, but hopefully it'll be clear enough to people
 
10:58 PM
Now to write a test!
 
11:12 PM
@rdlowrey The issue in Artax appears to be there in beta2. Earlier versions are not currently installable due to the acesync library having been moved, but I'm pretty sure I didn't see the issue in v1.0.0-beta.
 
utf8_unicode_ci if I want weird characters, right?
 
@webarto yes
 
thanks
 
init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
If you want all the weird characters, and not just some.
 
Pretty much European ones! Example turn on captions :P
 
11:22 PM
Just do mb4.....there's not reason not to...
 
yes sir
 
And I now have an extensive set of tests :)
Ah whoops... one sec
Fixed an error in the protected read test.
So, basically, <visibility> readonly means it's readable to <visibility> and writeable to <visibility> - 1, so public readonly is readable to public and writeable to protected, while protected readonly is readable to protected and writeable to private
 
@AndreaFaulds oooooooooooooooooooooooh shiny!
a bit rough as-is, but shiny =)
@AndreaFaulds Properties cannot be both readonly and private in %s on line %d - what's the reason for that?
 
@Andrea is on coke fire!
 
and also: can this be applied outside __construct()?
 
11:35 PM
@Ocramius There's no visibility lower than private...
@Ocramius Yes. It's not like C#'s readonly which is completely different.
@webarto I didn't know you could do just @Firstname
@Ocramius See some of the other examples.
 
@AndreaFaulds yes, but can't I have class ImmutableThing { private immutable $thing; public function __construct($thing) { $this->thing = $thing; } } ?
 
Three letters IIRC, everyone who matches will get pinged. @Andr
@*
 
@web huh
 
Pinged and pinged :)
 
@Ocramius Well, that has a completely different meaning. Adding immutable properties might be a good idea, but I'd call them immutable instead
 
11:38 PM
Well, I see read-only as immutable :)
this also disallows reflection hacks afaik
@AndreaFaulds is this an internal implementation detail btw?
like: change this constant: see the world of extensions burn?
 
@Ocramius No, it's just a practical matter
The point of readonly is to allow public readability but only be modifiable inside your class
If it's private-readable... to whom would it be writeable?
It doesn't make sense.
 
@AndreaFaulds it's: 1) protection from yourself and from reflection tooling 2) allows for future optimizations in projects like reckti and in the engine itself
 
No...
You're making a useless property then
As nobody can write to it
Because lower than private is only, well, nobody
 
The first assignment can write to it...
__construct can write to it
 
But that's not how readonly normally works. I don't want to overload it.
 
11:46 PM
and in general same scope can write to it, once
 
This proposal isn't like C#'s readonly
 
hmm... not getting the difference then
it seems just weird that I can't define private readonly
 
OK, let me explain
 
can you just add a test case to it?
 
I did.
 
11:47 PM
to show the actual real-world use-case scenario?
 
public readonly $foo is similar to C# public foo { public get; protected set; }
 
protected readonly $foo is similar to C# protected foo { protected get; private set; }
 
If tables are plural and models singular, for media it would be... media and media?
 
@Ocramius github.com/TazeTSchnitzel/php-src/blob/… this is a better example
 
11:49 PM
@AndreaFaulds so in the same scope I'm always allowed to modify the value?
 
@Ocramius Basically.
 
hmm
 
It's basically an alternative to getters and setters for a quite common use case: properties which users of the API should be able to read, but not write
 
@Ocramius did you say optimization? Because I think you said optimization:
8 hours ago, by Danack
They'd still be an overhead for checking whether the property is read-only....isn't it likely that marking a get method as final and getting opcache to inline that get function would be the only way to get a truly performant getter?
 
yeah, but the setter case is the most used one here
 
11:50 PM
We actually already use readonly in the manual
@Ocramius setter case?
 
@Danack you nailed it, yes
 
Any idea why a server would not like absolute URLs when you use them in a php include?
 
Oh yeah, this is almost certainly faster than using properties.
 
@AndreaFaulds most of the public stuff going on is typically (for performance reasons) public because we need to modify things
 
Because it's just a normal property with slightly different visibility rules.
 
11:51 PM
for example, symfony's form component does a lot of mutation of public data internally
 
Which still need to be checked when it's called?
@Ocramius BAD EXAMPLE DETECTED
 
@Ocramius This is to replace having getFoo() but not setFoo()
 
@Danack it's a bad example, but it's the current existing tradeoff
 
Like in literally every OOP interface ever :<
 
same goes for doctrine metadata as well: lots of public stuff because we read and write a lot on that stuff
@AndreaFaulds yeah, gotcha, it's just that it solves half of the problem this way: I got all excited because I thought immutable :P
 
11:53 PM
I don't see a point in immutable... though, this is a step towards it
It prevents outside mutation
If you're writing an immutable data structure, this'd be handy
class Vector { public readonly $x; public readonly $y; public readonly $z; } :D
 
@AndreaFaulds immutable allows to use completely different data-structures at low level
 
SQLyog > Navicat (for the record)
 
as you can really assume everything is gonna be read-only :)
 
@Ocramius Not really, in Zend PHP anyway
 
@AndreaFaulds yes, I know, I'm not aware of the macro stuff going on in there :)
 
11:54 PM
@AndreaFaulds the different visibility rules still need to be checked though right? Why isn't this a job for an post compilation optimiser?
 
@Danack Yes, they do... but it's the same code path as the normal access until the last function down the line
A getter or setter, on the other hand, is a completely different path
It also avoids calling any userland code
 
"isn't it likely that marking a get method as final and getting opcache to inline that get function would be the only way to get a truly performant getter?"
Marking methods as final could apply to other things other than getters.
 
@Danack Sure. This isn't a getter at all, though :)
The core of readonly's implementation is this: github.com/TazeTSchnitzel/php-src/compare/…
 
I've come to realise that you've got something against getters.....but it is a getter that you're optimising.
 
Nope, it's not a getter.
 
11:58 PM
@Danack getters are not OOP? :P
 
m'kay then.
 
It could be implemented with a getter, sure.
But that's not actually a getter.
By the way, I'd kinda like to be able to have properties in interfaces... :<
 
@AndreaFaulds that would couple state with a contract about behavior
basically defeating the entire point of an interface
 
@Ocramius Would it?
 
Yup
 
11:59 PM
Interfaces can have getter and setter methods in them.
I can't see why they can't have member variables.
 
Yes, but the entire backing structure isn't enforced
For example: class User { ... public function getName(); }
 
What do you mean by "entire backing structure isn't enforced"?
 

« first day (1466 days earlier)      last day (3473 days later) »