« first day (2440 days earlier)      last day (2502 days later) » 

5:00 PM
@Andrea ... it doesn't allow blocks, or didn't last I checked.
And doesn't allow changing binding types.
 
{ (Exception $x)
    throw $x;
}
 
Something between ) and body is necessary
This is why we decided we had to keep => for |$x| $x syntax.
 
@LeviMorrison no, why?
The => is synonymous to return here basically
But I do not consider it necessary for a block syntax
 
@LeviMorrison Can't we allow { $x => $stmt1; $stmt2; }?
 
naaaah
 
5:03 PM
@kelunik As long as return is not implicit, yes.
 
@LeviMorrison yep, that's the point.
 
{ (Exception $x) =>
    throw $x;
}
 
I think the => is unnecessary here
 
@bwoebi Above 40%?
 
@LeviMorrison I don't know.
 
5:05 PM
@bwoebi It has to do with likely future syntax eg () : Foo []
Hence the sigil.
 
@LeviMorrison I certainly do not consider no future block bodies as an issue at all.
 
@Trowski I know there are plenty of people who think so.
 
@LeviMorrison Does { => throw new Exception } currently work?
 
@LeviMorrison If we use a [] suffix. I do think we need array<Foo> though to be flexible.
 
@bwoebi I believe a similar issue may manifest with generics.
 
5:06 PM
@kelunik we could just write { throw new Exception; }
@LeviMorrison nope, < is not allowed as the start of a statement
 
@kelunik Is throw an expression? If it is then yes.
@bwoebi I think Foo[] is a likely syntax.
 
@LeviMorrison I dislike the syntax anyway and I totally wouldn't object if it were made impossible ^-^
 
Why not allow for both?
 
@LeviMorrison Don't think so. :-( 3v4l.org/fI8TI
 
@kelunik This is a feature I wish I had in JS so much
throw, debugger, etc
All of those are statements for no good reason
 
5:11 PM
@MadaraUchiha Let me tell you a story about Perl
 
@MadaraUchiha things without return value are generally statements…
 
@Trowski Could you have a look at the close behavior of file handles?
 
@bwoebi Let them return NULL
 
meh
 
Why should it matter?
Expressions can be in places that statements cannot
And you can always sweat a bit to convert a statement to an expressions with something like
 
5:12 PM
In order to allow predicates (trailing if/unless/for/while/etc), a lot of things are expressions. This allowed a particularly untalented coworker to write something along the lines of ($a && $b ? return 3 : return 7)
 
(function($ex) { throw $ex; })($ex);
But I think it's kinda meh
 
@kelunik Yes, I think that should be yielded. I'll update it later, it's not vital.
 
$foo ? throw new Exception() : return 5;
 
@kelunik Sure.
 
@Dereleased I don't care.
I don't design my programming languages for idiots
 
5:13 PM
@LeviMorrison does it not? $x ==> {} worked IIRC
 
If you abuse the language features, it's on you.
 
@Trowski And please review the latest exception changes, I think we're fine with a 0.2.0 release then.
 
oh nevermind
 
Also, are you suggesting that PHP's features (or JS's, or Java's or C#'s or....) are not already abused on a regular basis?
In my eyes, while ($row = $stmt->fetchRow()) { is horrible abuse
 
People are already given enough rope to shoot themselves with; $mood ? "What's a little more?" : "We shouldn't give them more"
 
5:15 PM
@MadaraUchiha Just use function raise(Throwable $t) { throw $t; }, no need to define it everywhere.
 
@MadaraUchiha back in time we hadn't had iterators…
 
@bwoebi Welcome to the second millennium
Where writing C is optional
To me, that line is totally writing C in PHP
 
@MadaraUchiha I'm totally not arguing that foreach () over an iterator would be much better here …
 
And you see it everywhere in PHP code written by "less talented people" and even those written by your average PHP devs
But I digress
@kelunik Sure, you can do that, but then you lose the explicit throw keyword in your code
Which is extra cognitive load
(Plus the extra function in the error stack)
 
@Andrea It's not in the docs if it was added.
 
5:18 PM
OT: what happens in 26 days?
 
@MadaraUchiha The way you talk about this makes me not want to ask you what the right way is, but if I don't I won't learn your thoughts. What is the right way to do that?
 
@Dereleased foreach over an iterator?
Also, don't be taken aback by my aggressiveness in arguments, it's my way to invoke some subset of Cunningham's law to get people to voice their opinions more freely
Feel free to call me out if I'm being too blanketing with my statements, I'd appreciate it.
 
@MadaraUchiha I also see fetchAll() with PDO getting used more often with foreach …
 
@bwoebi That's bad for a different reason though
Leading a huge resultset into memory to iterate it sounds like a really bad idea
I mean, we regularly query against millions of rows during request processing
 
if it's huge … most resultsets aren't that large though.
 
5:22 PM
@bwoebi Until, one day, they are.
That's the exact problem we've had in our previous company
Everything worked just fine when we had 50 clients, everything broke down and exploded randomly when we had 50,000.
The resultset into memory came into focus then
 
@Dereleased I agree with foreach here. I also think assignment should not have been an expression.
 
Because each client had about a thousand rows to inhale, and suddenly you have 50 million records you need to put into memory
The company kept increasing the machine's power instead of fixing the root problem (mostly because everyone were too afraid to touch the admittedly fragile PHP code that powers about 70% of the company's income)
 
@MadaraUchiha well, then sure. But that's your fault if you do subqueries multiplying your actual resultset size
 
@bwoebi No subqueries in that particular one
It's just that there were genuinely around 1000 records per client
That's not too many, really.
But multiplied with ~2kB per record and 50,000 clients, you get a huge blob of data
 
well, you selected all the records from all clients simultaneously. That's a bad idea.
 
5:27 PM
We did have queries with subqueries and outer joins (wtf?) with no proper indices. Increased performance by a power of 5 when we fixed that one :D
 
either all clients or all records of one client…
 
@bwoebi No it's not, I need to create a report and aggregate the data
I don't mind if it takes an hour to run, but I don't have 100GB of RAM ot spare to this task.
When we changed it to iterate the cursor instead of dumping everything into a huge array, it worked just fine.
The cursor still had 50 million records to go through, but it went through them one by one, as expected.
 
@MadaraUchiha maybe you do. But you could've just processed one client after the next. (at once) … sometimes it's better to just do multiple queries.
 
@bwoebi Yes, that's true.
 
Also, your query result will be somewhere cached. Either on your side or the database side.
 
5:34 PM
But it was a big complicated query that I didn't dare touch at the time.
I'm talking about a 100 LoC query here
 
… wow.
 
@MadaraUchiha is fetchRow() already an iterator now? I haven't written anything in PHP that queries a DB in some time
 
@Andrea What about nested objects?
@Dereleased It wasn't when I wrote the fix. I implemented iterator myself.
 
@MadaraUchiha It won't appear in the stack, as traces are generated on creation in PHP.
 
5:36 PM
$foo->bar??->baz?? like this?
 
@LeviMorrison I don't think you'll sell me on that idea, but please try anyway
 
@MadaraUchiha that would nullderef … with that proposal at least.
 
@kelunik Why wouldn't it? The throw is inside the raise() function that's called from the outside
 
If anyone has some Magento experience...

https://stackoverflow.com/questions/44658724/getmodel-returns-object-but-load-is-called-on-boolean/44671569#44671569
 
@MadaraUchiha As said, exceptions generate the stack trace on creation, not on throw.
 
5:37 PM
C# has a .? operator which I want in JS very badly as well
 
I hate this platform so far.
 
@kelunik On creation of what?
 
@MadaraUchiha of the exception object
 
Ah
I see
 
5:38 PM
Hmm, I wonder what's the behavior in JS is
 
same
you're supposed to re-create the exception, afaik
 
@MadaraUchiha Do you mean ?., e.g. mightBeNull?.Property?
 
@Dereleased Yeah, my bad
 
@MadaraUchiha Yeah I love that feature. So nice to write switch( object["index"]?.Property ) {
 
what's not to like with if (object && object.property && object.property.subprop && object.property.subprop.killmenow) {}
 
5:39 PM
JS is on throw.
 
What's the name of a variable into a class?! Field?
 
Interesting, that behavior never occurred to me.
@Shafizadeh Static field
 
Isn't there any other name for it?
 
@Shafizadeh No?
Static property, maybe
 
I think I have heared something else already
@MadaraUchiha aha, property, thx
 
5:41 PM
@FélixGagnon-Grenier Although to be fair, PHP's isn't much better in that regard...
($foo && $foo->bar && $foo->bar->baz) is still a thing
Even with Andrea's RFC'
If I'm reading it correctly
 
to be honest, I never had to do this.
 
Maybe you'll be able to skip the $foo check
@FélixGagnon-Grenier With type-hints you wouldn't
 
I never not know what type is an object.
yes exactly
 
That's the reason I like TypeScript so much
 
5:42 PM
I haven't written an endless && check like this in months
 
gods be blessed ;)
 
@Dereleased Which?
 
@MadaraUchiha I'm very rarely writing that even in PHP…
 
2 mins ago, by Madara Uchiha
@FélixGagnon-Grenier With type-hints you wouldn't
The thing with JS is that your primary data structure is the associative array (or "object" as JS calls it)
Whereas PHP's primary data structure (if you can call it that) is the class
You don't regularly have functions and nested properties in nested associative arrays like JS does.
 
@MadaraUchiha Nah, PHP's primary data structure is still the associative array.
 
5:46 PM
When normalizing a relational DB if two domain objects have say 3 columns that the other does not have, but share 10 should there be a table for each domain object with the three unique columns in it and a table with the 10 shared columns, or should there be two tables, one for each domain object, where each shared column is a reference to a type table?
@Wes
 
Sounds like you are normalizing wrong
 
having NULL in a column is totally fine.
 
How are the domains objects related?
 
@Jimbo EXISTS() is supported in DQL
 
Ikea has cabinets with names and employees with names
Doesn't mean you should put it all together
 
@FélixGagnon-Grenier Well, yeah. But you want to avoid that if they're logically different domain object.
Anything that is an independent type should be a table, right?
 
@Allenph if they are logically different domain object, they should not be linked in the database to begin with
 
54 secs ago, by PeeHaa
Ikea has cabinets with names and employees with names
 
@PeeHaa Ikea probably also has customers with phone numbers and employees with phone numbers, too.
But you want a phone number table.
 
Do you?
 
5:52 PM
Yes...
 
why not a person table with a normalized status field? ^^
 
No you don't
 
Or else you'll end up validating phone numbers in some kind of helper.
 
That means an employee can never be a customer
 
5:53 PM
Scratch that actually
But what you say makes no sense
@Allenph wat
 
I'll have to validate phone number in more than one place if I have phone number columns in more than one table.
 
wat
 
wat indeed
 
Let me guess you have "models" named as your tables?
 
@PeeHaa No. But to be fair, that's where I'm moving out of.
I realize the failure of active-record.
 
5:55 PM
You don't realize all of it apparently :P
if you think validation equals storage something somewhere is doing too much and in a weird way
 
lets say you have a list and when you have no filtering you can get 20 post by loop through start point and end point but with filtering now only one post can be shown.
how should I handle that
so that its always 20 posts
 
@user7594714 I don't understand your question.
@PeeHaa I read Eric Evans. But I think I'm missing some underlying stuff...like this.
 

« first day (2440 days earlier)      last day (2502 days later) »