« first day (2424 days earlier)      last day (2515 days later) » 

3:00 PM
@PeeHaa thanks. It's making sense now.
 
@LeviMorrison I would be happy to know how you disambiguated braces.
 
@brzuchal {} are only allowed at the top level.
(currently)
Which means that there is exactly one case you have to worry about:
expr;
 
@brzuchal ->any({AbstractWhen->matches}) <-- that's weird and counterintuitive (if it behaves how you're implying. Otherwise I think that's a novel approach
 
Not too difficult to fix.
Just make a new rule that is the existing expr and then make expr have the new rule as a child, then add a rule to expr for the new syntax. Then make the expr; rule use the new rule instead.
 
@Rovak your MVC is bad and you should feel bad
TBH, I am not even sure why you insist on calling "MVC"
 
3:05 PM
i know, its a minimal example
 
@Rovak Is your View in sync with the Model, so when the model updates the view does too, say, via the observer pattern?
 
There's only slightly more to do because expr is left-recursive; have to make the new rule left recursive on itself instead of going to expr.
 
but please be more specific about what is bad
 
@bwoebi You wanted () {} one day, right?
I mean some block syntax, not necessarily that one?
 
I just realized I replied to the wrong message up above. ._.
 
3:06 PM
@Rovak no, it is not a minimal example of MVC approach. Just an extremely simple example of generic SoC approach (which shitty routing approach)
 
@LeviMorrison maybe, but with fn() I think.
 
@Rovak Because you have a Separation of Concerns, which is useful. But not MVC.
 
With block syntax I think binding by-value is not a good choice.
 
@Rovak also, next time, dont try to squeeze bootstrapping in a class just to "make it oop"
that's silly
 
ah well, i tried to keep it simple, mvc can be just a way of organizing code
 
3:09 PM
@Rovak not really
 
god, I'm teaching a bunch of grade-schoolers programming next week
 
it is a name of an architectural pattern
 
then where should you put the bootstrapping code?
 
@Rovak in a simple bootstrap.php file
 
so we have different approaches, that doesn't make it wrong
 
3:10 PM
php is not java, where you code must be inside a class just to keep up a pretense
 
@Rovak No, it makes it not MVC.
 
well i'm mostly a Scala developer, haven't done any real PHP programming in 3 years
@Jimbo then point me to a source which explains your way of MVC
 
@Rovak your "view" is just a dumb template, your "controller" is responsible for rendering and routing ... and there is no model anywhere. It is not MVC. Stop trying to advertise it as such
 
@Rovak It's not "my way of MVC"...
 
seriously, i tried making an example for a beginner coder and you are gonna complain about some details? instead of complaining you could put that effort into helping others.
but still, @Jimbo point me to a source
 
3:14 PM
Well, first... lose the attitude. We help others a lot on here.
 
i know it isn't a perfect "MVC" example, but it did help clarify some stuff for someone who is struggling with the beginner stuff
 
@Rovak Although I absolutely have large reservations about anything Microsoft, especially a lot of the content on this page... [msdn.microsoft.com/en-us/library/ff649643.aspx](MVC from MS)
> Observer. This pattern is often mentioned in conjunction with MVC due to the need to keep the views and the associated model synchronized.
 
@Tiffany the use statement imports the variable from the "containing scope" inside the function. It's basically a quick syntax for achieving currying (otherwise known as "partial application functions")
 
observer isn't needed for mvc?
 
Then how else are you going to keep the model and view synchronised without going through the controller layer each time? Websockets? Sure, but not easy...
 
3:16 PM
@ircmaxell Even given that it requires an ugly tokenizer hack or a GLR parser?
 
we aren't talking about frontend views here like react, angular or vue. it's just a one-time render
 
@Rovak your example was not imperfect. It was completely wrong. There is a significant difference.
 
@Jimbo ASP.net MVC isn't that relevant to PHP anyway. It's actually closer to what you might call "traditional MVC" than anything in PHP because of a butt-load of magical stuff.
 
"completely wrong", by missing the model?
 
Zend/zend_language_parser.y:1356: undefined reference to `yystrlen'
Hmm. I wonder what I did wrong.
 
3:17 PM
@Rovak it was also missing views and controllers
 
it didn't?
 
@DaveRandom Hence my reservations about MS ;) - In fact, I seem to remember talking about this page or similar with you from MS a few years back and you saying the same thing
 
@Rovak it had a template and some abomination containing bout rendering of a template and routing
 
you didn't even read the code did you?
 
@Rovak yes, I actually did
 
3:18 PM
then you must have missed the view class
 
aka not a view
 
then what do you consider a view class?
 
something that contains presentation logic
and what that entails would take way too much to explain right now
 
which can be done with ordinary php
but i guess you are referring to twig and blade as view classes
 
3:21 PM
@Rovak no, I am refering to twig as templating
 
@LeviMorrison honestly, yes. The mechanics of the parser should be simple, but the readability and syntax of the language takes preference IMHO.
but that's just me and I'm happy to be wrong there
 
I'd prefer a syntax that doesn't require it but honestly I'd be fine to move to a GLR parser as well.
 
@tereško then do you have an example of a php view class library?
 
I suspect many new languages are already going straight for GLR-like parsers (though hand-rolled).
I'd be surprised if Swift wasn't that way out of the box, for instance.
 
@LeviMorrison Oh, I'm with you there. The only thing is if there's a good syntax that doesn't require it, then awesome. But haven't seen a great one, just alternatives
 
3:23 PM
Eh, I think features wise the C++ syntax hits all the marks.
 
except for readability ;)
 
Yes but you learn to read it once.
 
@Rovak there are no libraries to make view classes. Same way as there are no libraries to create controller classes.
 
I'm fine with that given there is precedent (some new unreadable syntax would probably be a no-go).
 
well, it's not about learning, but more about recognizing at a glance
 
3:25 PM
Yeah, the brain will learn that quickly.
 
@tereško i may have worded it wrong, but i mean is do you have an example of a view class/library
 
@Rovak nothing that is opensource. You can try reading this, if it helps: stackoverflow.com/a/16596704/727208
 
@tereško then why do most people refer to Zend/Symfony/Laravel as MVC frameworks? if there are no view classes
 
Symfont specifically states its not
 
@LeviMorrison one person's brain. We're not talking one person though. We're talking literally millions...
 
3:27 PM
As in , Fabian Potencier wrote a blog post detailing how they don't specify it as MVC
 
@Jimbo Nor does laravel cc @Rovak
 
@ircmaxell I'm sure the payoff is far greater than the effort expended.
 
Laravel did at one point for marketing
 
I don't know about that
 
athough I couldn't find evidence of that
 
3:28 PM
hmm, i thought it read it somewhere, but i haven't been keeping up
 
wayback machine?
 
It didn't afaik. And wayback agrees with me
 
For me the biggest importance is when you have a few of them in close proximity in the code.
Our existing syntax and semantics is fine for isolated usages.
 
@Tiffany Yep tried that
 
The issue is when it becomes dense.
 
3:30 PM
well i found a few laracast refering laravel as MVC, but i don't find that a credible source after the visual debt video
 
yes almost like random people name stuff mvc ;-)
 
I've been thinking more about where we see high density. The first I thought of immediately are collection style operations map, filter and reduce. The second was async callback hell. Would short closures really help the latter that much? And where else do we regularly see high density use of closures?
 
The term mvc in general is utter bullshit when talking about just php. Any time spend talking about it is counter productive imo :)
 
Anonymous
^ this
 
well i agree, the term MVC means a lot of different things to different people. i just didn't expect the negative response after posting a simple "mvc" example.
 
3:33 PM
@JayIsTooCommon this is a test
dammit
 
@Rovak Did you learn anything?
 
5 messages moved to Trash
 
If so, negative response = wrong ;)
 
ugh, I'm going to have to actually debug it aren't I
 
Anonymous
@DaveRandom I hope you have just as many problems as I did, in a nice way.
 
3:36 PM
@Rovak I just note that calling something mvc in php is weird taht's all :)
 
Anonymous
Just separate your concerns and use a different language, simple.
 
@Jimbo nope, a negative response isn't by definition wrong. try telling religious people that there is no god
 
Anonymous
@tereško there is no god.
 
@JayIsTooCommon I know. What was your point?
 
@JayIsTooCommon clearly you haven't met John Resig
 
3:38 PM
lol
 
@Rovak too meta for this room haha
 
@PHPeeHaa this is a test
 
Anonymous
oh golly, what a shame (inb4 mods)
 
hahaha
 
Anonymous
3:40 PM
that's bull shit.
 
s/bull shit/sparta
 
it worked first time, jay just doesn't have a profile link
 
@LeviMorrison from experience in other languages, it doesn't help much in the latter case.
 
how does it find the right twitter name for SO name?
 
Anonymous
3:40 PM
I did that.
 
Anonymous
i rather dislike you
 
:-P
 
Anonymous
Everything about you, I rather dislike.
 
sorry
I'm guessing your problem was a composer one rather than a PHP one
 
user6845426
Looking at: PHP 7.1 VC14 TS .. can someone tell me what VC14 TS stands for?
 
Anonymous
3:42 PM
Jon has made me nervous about my language.
 
@dipper VC = Visual studio Compiler
 
Anonymous
@DaveRandom I'm more angry than I was when it wasn't working... i'll crack on with the other issues.
 
TS = Thread Safe
 
@LeviMorrison An accepted proposal does not mean we're accepting the implementation ;)
 
user6845426
Awesome, thanks guys
 
user6845426
3:43 PM
Is it better to download the TS version
 
@dipper yes
 
@JayIsTooCommon I'm genuinely sorry. At least the github username retrieval should now work for you.
 
@dipper No
You probably don't need it
 
user6845426
Maybe so?
 
Foodness brb
 
user6845426
3:44 PM
Yeh, I don't think i do :)
 
Anonymous
@DaveRandom lol, don't be. chat.stackoverflow.com/transcript/110670?m=37467418#37467418 I called it a while back.
 
Ahh I see, one of those days
 
@PeeHaa it adds no additional overhead in practice
 
/me goes home
 
you only get free lunch like being able to use pthreads
 
3:45 PM
I doubt that?
Fo realz?
 
@PeeHaa I've tested it.
on stuff like drupal homepage or magento
the difference is negligible
 
I don't like bison conflicts sometimes. It's giving me a conflict but I'm not seeing how it conflicts >.<
 
@PeeHaa if you don't believe me, I can let you test on platform.sh :P
 
brb @FlorianMargaine
might test it myself later
food > php
 
Wish it would generate a parse tree / derivation that shows a specific example...
 
3:47 PM
@PeeHaa you eat at 6pm?
what are you, a grandpa?
 
:P
 
@dipper there is almost no documentation for ecmascript and javsacript versions
 
@tereško "thread safe"
 
user6845426
@tereško of what?
 
user1804599
emacsscript
 
user1804599
3:49 PM
:illuminati:
 
user6845426
Im confused.
 
Anonymous
one of those #10 weirdos
 
user6845426
But then that doesn't take much
 
@dipper explains how I am about 90% of the time
 
user6845426
How can it be so hard to set up a debugger :p
 
Anonymous
3:51 PM
var_dump is built in, don't worry.
 
@ircmaxell so how would you propose short syntax for closure in ´of([new Foo, new Foo])->map(function(Foo $foo){ return $foo->getBar(); });´?
 
user6845426
@Tiffany do you use Phpstorm?
 
@brzuchal By using a short closure
 
@ircmaxell it's not binded class method which needs to be called for each Foo
 
That's not something that should be handled by callable syntax
 
3:53 PM
@dipper yes
 
@NikiC but short closure is longer
 
@dipper I would be less productive without it
 
user6845426
Yeh I managed to get it for free. Neat isn't it
 
user6845426
Better than Sublime anyway
 
Work has paid for a copy for me to use at work but I own a personal copy as well.
 
3:55 PM
@NikiC you mean smth like this ´->flat((Foo $foo) => $foo->getBar())´??
 
Never really got into using Sublime. I set up notepad++ the way I like it and haven't bothered trying another text editor. That is until I've started using VS Code for front-end code. (thank @MadaraUchiha)
 
user6845426
You use 2 different editors for front-end/back-end?
 
I use VS Code for front-end (HTML, CSS, JS) and Phpstorm for PHP.
I sometimes use npp for front-end but that's if it happens to be open on my second monitor and is readily available to use.
I have three editors open right now
 
what does phpstorm lack compared to vscode?
 
@tereško Router is starting to make sense. It requires a single-point of entry to work, which I think is what I was confused on. Not sure why it didn't dawn on me before.
 
4:02 PM
@Rovak free ram
 
haha, true
 
@tereško I have 32 ¯\_(ツ)_/¯
 
@Tiffany It's a question of expressiveness
 
@Tiffany Visual Studio 2017, Visual Studio for Mac, Visual Studio Code, Komodo IDE, vim
 
@FlorianMargaine yeah .. but you also need to run Chrome
 
4:04 PM
You can define your routes with .htaccess or even nginx conf
Or you can define them with PHP
 
@tereško lol
 
PHP is much more expressive and readable :)
 
@brzuchal with a closure, not a callable syntax. Because you're not actually calling the method you're indicating, but a different method that's just conforming to the signature based on a parameter
 
usually when I'm writing HTML/CSS/JS lately, it's for one-off stuff that I'll be embedding into page. PHPstorm works more efficiently with projects. I know I can create new files that aren't part of a project but it feels less awkward to do it in VS Code than phpstorm.
 
@MadaraUchiha it's also much easier to maintain PHP code using a front controller
 
4:05 PM
I haven't wrote front-end code for a full website in a such a long time. ;_;
 
btw, @MadaraUchiha, how does VS Code compare to Brackets, when doing frontend work?
 
isn't Brackets dead?
 
I recall it getting and update not long ago
 
@MadaraUchiha And PHP works with nginx, apache or the built-in server :)
While server config obviously does not
 
meaning given class Foo { static function b1($a) {} function b2($a) {} } your Foo::b1 returns closure(array ...$args) { return Foo::b1(...$args); }, but Foo->b2 returns closure(Foo $foo, array ...$args) { $foo->b2(...$args); }`. whisch is unintuative and odd
 
4:06 PM
@ircmaxell yes but this is the same as just returning closure from csllable with binded $newthis for every foo
 
@Tiffany Have you made yourself a tool yet for executing little bits of arbitrary code without having to interact with the filesystem?
(or paste into 3v4l, which is not always desired)
 
Anonymous
@PeeHaa sorry for pings.
 
@PeeHaa sorry for the ping
 
@PeeHaa sorry for the ping
 
@ircmaxell set up a sphinx env again today and fixed up our master branch so it matches what's on the site
 
4:07 PM
there's a bot function for that
!!annoy @PeeHaa
 
@‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa @‌PeeHaa hi
 
I'm a terrible person.
@Dereleased not sure what you mean in the context of HTML/CSS/JS
 
@PeeHaa I'm not sorry for anything
 
@NikiC nice :)
 
@Tiffany I meant for PHP. I misread your statement, I thought you were talking about not liking creating one-off PHP scripts (probably for testing small things) in PHPStorm because it felt project-oriented.
 
4:17 PM
@brzuchal but that's different than what's happening in other cases though, making it a bit counter-intuitive
 
@Dereleased for one-off php scripts I sometimes use npp, but most of the time I find a way to make a new project for the code (I have several that are unused at this point). I think I've used the "create new file not in project" feature like once or twice.
 
@tereško Haven't tried Brackets, honestly.
 
@ircmaxell Actually it's not different it's the same as {$foo->getBar} but the difference is this closure is not binded yet and has no $this binded
that's the only difference
 
@brzuchal yeah, but what gets bound as $this?
 
// I have a grammar for list comprehensions mostly working:
$result =
    foreach ($comics as $comic)
        if (in_array($comic['id'], $store))
            yield $comic['id'] => $comic['name']
;
 
4:21 PM
you're not returning a closure with an instance, you're returning an uncallable closure.
 
@ircmaxell His plan is to require $this to be bound on call.
 
@LeviMorrison ooooooo
 
@ircmaxell map() function do this for every Foo from collection
 
@brzuchal that's not how map works internally though...
 
@ircmaxell I was goint to mean flatMap and was thinking about exampoles in Scala alvinalexander.com/scala/…
 
4:23 PM
I have a dangling-else issue I bandaided over but that's a famously solved issue and is just some time investment to fix ^_^
 
I totally get what you're after, and I think it's awesome, but it's got to be consistent, and as a language feature, it has to work with the rest of the language, not just a new corner. I do like the inventiveness though, that's something we don't see a lot (brand new ideas and completely new concepts). While this particular case I don't personally like, I do like the direction of the rest of it
 
val fruits = Seq("apple", "banana", "orange")
fruits.map(_.toUpperCase)
 
If we have list comprehensions we don't need to resort to the method closure stuff as often, btw.
 
@ircmaxell Is the info in the domains here still correct? github.com/phpinternalsbook/PHP-Internals-Book#domains I.e. do you also have the other two?
 
I think so, let me check
 
4:25 PM
@ircmaxell Ok, so you think the whole syntax for closures from callable is ok until it's complete callable yes?
 
@brzuchal I like the overall approach, the instance callable I didn't like (Foo->bar), but the rest I personally find refreshing and nice
 
THX
I'll think about that specific example maybe there is another way
I wanted to cover Scala Calosures in this flatMap call somehow in PHP
Scala has the _ (underscore) for unneded arguments and few other things, and there is the gap
 
@NikiC I have both, they don't point anywhere, but I own them
@brzuchal that would be nice :)
 
@brzuchal ^_^ for making closures too
 
Yes but there are most of symbols in PHP already reserved :(
 
4:31 PM
_ is a function in an extension and is widely used.
(unfortunately)
 
@LeviMorrison Sure I'll prepare RFC for short closures from callable syntax - how would you name it?
Some short name for it
 
@brzuchal I meant _ is used in Scala to make closures as well (not just unneeded params)
 
@brzuchal So basically a syntax for Closure::fromCallable()?
 
Is it function/method dereferencing? I think no
@Trowski Yes
@Trowski Closure::fromCallable([$foo, 'getBar']) would be same as {$foo->getBar}
 
@brzuchal Oh, even better. :-D
But {$someVar} is valid right now… that would seem to be an unacceptable BC break.
 
4:37 PM
@Trowski this is not because of missing semicolon and braces are awailable only in top statements
 
@LeviMorrison except that it wouldn't be a collision, since the function context is distinct from the parameter context
 
I mean top level code blocks
 
Hey folks! I'm trying to test a custom Doctrine2 repository that I wrote, but I can't seem to figure out how to instantiate it for test. All of the tutorials I've read suggest that I use $em->getRepository('entityName'), but that seems like it tests both the repository itself and the fact that it's correctly to the entity. What I'd like to do is say $repository = new PersonRepository(); and then call methods on that concrete class. Is there any way I can do that, or something similar?
 
@ircmaxell Depends on how restrictive you want it to be, but if it's fairly limited then yes there is no conflict.
 
4:38 PM
@LeviMorrison true :)
 
Anyone feel like implementing VM support for this?
18 mins ago, by Levi Morrison
// I have a grammar for list comprehensions mostly working:
$result =
    foreach ($comics as $comic)
        if (in_array($comic['id'], $store))
            yield $comic['id'] => $comic['name']
;
 
@brzuchal $object->{$someVar} is valid. If you can disambiguate that, then great.
 
@DaveRandom Thx
@Trowski I don't need because it's different syntax
It's getting object property by name
 
@brzuchal $bar->{$foo->method} currently would be the property of $bar with the name given by the property method of $foo
 
My syntax is different and it's an expr like assigning or passing as an argument only, because other thing are not usefull
 
4:42 PM
@Trowski What do you think about my earlier pings?
 
@Trowski Yeah, but my syntax would work only for $a = {$foo->method}; or call({$foo->method}); in other cases creating closure is not usefull
 
@LeviMorrison What's the use case?
 
@brzuchal Right, and there isn't a parser problem then with the above example?
 
@kelunik I can have an intuitive map/filter that works on everything that's iterable?
 
It should be doable because there are only braces used in code blocks in top statements and all of them need valid statements and those need to end with ; semicolon, right?
 
4:44 PM
@LeviMorrison question on that, is that returning a generator? Or an array?
 
@LeviMorrison It's not intuitive IMO, it's way too verbose.
 
$result = foreach ($foo as $bar) yield $bar->baz;
that is actually kinda nice...
 
@ircmaxell Generator since it says "yield", probably. I think we can make it do an array via syntax:
$result = [foreach ($foo as $bar) yield $bar->baz];
 
that would become ambiguous though, if you support both
since how would you differentiate [$generator] from array($generator)?
 
Would only take me a few minutes to find out for sure but I don't think it's ambiguous.
 
4:46 PM
meaning do you want an array with the first element being a generator, or an array from a generator
 
Do the "wrap it in parens" technique for the latter.
 
Evening
 
@LeviMorrison yeah, but isn't that odd?
 
$result = [ $comic->name | $comic <- $comics, in_array($comic->id, $store) ]; <-- in Haskell's syntax.
 
@ircmaxell Meh.
 
4:49 PM
But it doesn't really fit into PHP.
 
@kelunik It would conflict in the grammar.
 
But I'd just like that:
$result = $iterable
    ->filter(function ($comic) => in_array($comic->id, $store))
    ->map(function ($comic) => $comic->name);
 
@kelunik Firstly... that's not actually identical.
And it's worse to read :D
 
$result = $iterable
    ->filter($store::contains)
    ->map(($comic) => $comic->name);
@LeviMorrison Yes, it doesn't have the keys.
 
Still not identical.
 
4:54 PM
@LeviMorrison Yes, it's the same as above, but without the in_array.
 
@kelunik it's not complete then if there is missing in_array, there could be some closure passed to filter collection, and you gave just a object constant
 
@brzuchal It's just pseudo code mimicking Java.
 
The example I chose was not arbitrary; I made sure to pick a semi-realistic example that uses multiple features of the comprehension ^_^
 
@kelunik This seems like a much more reasonable difference, with the latter supporting back-pressure, correct?
 
I know there is a lack of usable and free symbols in PHP language, but you cannot use something what is valid syntax for different purposes
 
4:57 PM
@Trowski No, completely without backpressure.
 
posted on June 05, 2017

New Cyanide and Happiness Comic

 
There's a bench/parser.php you can run.
@brzuchal I know.
 
This specific example is not easy to replicate with anything else aside from doing what I just wrote inside of a closure, but even then you have to close over$comics and $store or take them as parameters.
 

« first day (2424 days earlier)      last day (2515 days later) »