« first day (2416 days earlier)      last day (2526 days later) » 
00:00 - 19:0019:00 - 00:00

7:00 PM
Is imo not tutorial information
 
I... kinda agree with that. It's at the very least, not beginner tutorial material, which is the goal of that, if I understand correctly
 
correct
 
I mean, if we look into the last hour, people were not exactly fluent with a switch case. Thinking about oop is... not the thing to do.
 
damn ... I need to write some code
otherwise I will have made no progress in the entire weekend again
 
iknowdatfeel.gif
 
bob
7:03 PM
@FélixGagnon-Grenier Hold on that's actually not true, i thought the switch was already in the file.
 
... which is exactly what I mean by "not exactly fluent with switch case". take no offense from it, really!
 
@PeeHaa IMHO tutorial can have several levels, for newly programming begginers and those who know something for ex. about JS and a little about OOP to
 
one should not be ashamed of the situation they are at.
only of the lack of open-mindness to move from it
 
@brzuchal That's it not a tutorial. That is a book :P
/ books :)
 
@FélixGagnon-Grenier ... or I could read more about "loop quantum gravity" and the "time as emergent property"
 
7:06 PM
ah fuck. I've just had this urge to play factorio, again.
 
it's basically the "space is quantized at small scales" approach
 
bob
Ok I have a quick question who here learnt everything they know on their own? and who else went to a course/uni/some form of school?
 
I am not really compatible with course/uni/some form of school
 
@PeeHaa Yeah, well maybe you're right. I see there is a note: For more (indepth) information about a specific topic please refer to the official manual. in Introduction maybe it'll do the thing.
 
@bob I started learning programming when is was 15 (from a russian book, using a dictionary) , and I taught myself PHP while I was in university
 
bob
7:10 PM
@tereško You're Russian?
 
@bob I've learned most of things on my own. school and university gives me only some teoretical bacground expecially technical university, but programming in PHP etc. on my own
 
@bob no
 
I studied Chemistry and Molecular Physics at university. The only programming we were taught was in Fortran 77. Which is a language older than almost everyone here.
 
bob
Wow you guys are awesome.
 
user6845426
I'm playing around with Twig just trying to get some basic overriding. I've created this twigfiddle which attempts to populate my content div with another html file. It isn't working for me, just wondering if someone could take a look twigfiddle.com/zs6i4v
 
7:25 PM
@kelunik Can you explain why you think stream_socket_client should throw? It seems to not need it, as if it fails it returns false, rather than resource, which is checkable, and also will make any attempt to pass it to fwrite also fail.
 
@dipper you are rendering the wrong file
 
@dipper click the child template to be the main template.
aka the content one, not the base one.
 
user6845426
Yeah that worked. A little confused why though
 
user6845426
I thought everything is pulled from loading the base template
 
class child extends base {
if you write new base would you expect it to know about existence of stuff in the child class?
 
user6845426
7:29 PM
So what if I have a base template and I want to have seperate files for its header, footer etc
 
user6845426
If I render the header file, how would I load the footer also? Or am i looking at this incorrectly
 
@dipper you can not only extend but also incude
 
user6845426
Ok so if I use include, does the base_layout become the base class?
 
user6845426
Thanks btw
 
@dipper depends
 
user6845426
7:32 PM
on
 
do you want that part to be included in all the child template or only in one specific child template
 
user6845426
I basically want to create a base file which lets me pull the header, footer and then the content will change as a user navigates
 
Anonymous
Nin
 
8:25 PM
nong
 
8:37 PM
I think I found inconsistency or a bug 3v4l.org/UhM9D
Using relative static class method call (As of PHP 5.3.0) - method can be called using call_user_func but cannot be passed as a callable.
 
@brzuchal there's a whole load of shenanigans wiki.php.net/rfc/consistent_callables - I'm just about to post that to the list after changing 7.2 to 7.3
 
@Danack thanks, I've started drafting my new RFC about short syntax for... closure from callables syntax (I think it is the right name) I mean I'm going to propose adding syntax for passing closures using braces like: $closures = [{ClassName::staticMethodName}, {$obj->methodName}, {ClassName->nonBindedMethodName}, {NamespacedOrNot\function_name}];
 
what's a nonBindedMethodName ?
 
@brzuchal oh yeah I wanted to do that somehow
I didn't like any of the options for new syntax much, though
and one of my attempts was already rejected by internals (or I withdrew it because it seemed to be?)
@brzuchal using { syntax is probably going to be parser hell because of ambiguity
 
@Danack mostly because you don't want to check the return value.
 
8:52 PM
@kelunik why not? For context, I strongly don't want the discussion to bring in fopen(), and it seems that stream_socket_client is equivalent in that you can either check the return type, or just watch the next function call fail, when you try to pass false as a resource.
 
it's a closure made from object method but not binded to object instaance, it's like
$date = new DateTime('now');
$closure = Closure::fromCallable([$date, 'getTimestamp']);
$closure->bindTo(null);

$date2 = DateTime::createFromFormat('Y-m-d', '2017-05-28');
var_dump($closure->call($date2));
But without error
@Andrea I heard that, but I think that might be possible
 
@brzuchal ah, something to deprecate and remove then? /troll
 
Why deprecate?
 
Because, to me, it's nuts. An instance method that has lost its instance.
aka I don't see why it's needed.
 
@Danack you can then array_map it or whatever if you make the instance into an argument
 
8:56 PM
I found that this might be usefull instead of writing $closure = static function (DateTime $date) { return $date->getTimestamp(); }; $closure($date2);
 
So kind of dynamic method declaration?
 
@Danack exactly as @Andrea said, AFAIK it's widely used in monads
 
Monads? fetches fire
 
Something like that, very usefull in mapping array of same class objects
Some guys are using them. So why don't give them somethiing usefull.
$closure = static function (DateTime $date) { return $date->getTimestamp(); }; $closure($date2);
$closure = {DateTime->getTimestamp}; $closure($date2);
Equivalent
Let's say there are 4 ways passing closures using this syntax and one of them is targeted for mapping only (when setting $newthis is a must)
@Danack how about that? do you fell it usefull?
 
I can see how it's useful, but I still don't have to like it. It's like a patch for a missing feature in the language.
Like C sharps ability to split class definitions up into separate parts.
 
9:06 PM
Are we talking about functions as first class citizens?
 
I think that might be usefull on refactoring because there are no strings used and just FQN's with method name
 
Ah, talking about passing functions around without strings
Yeah, it's one of PHP's sorely unaddressed weakpoints.
 
Yes, that's what I wanna do
 
9:48 PM
@kelunik In case I forget, after your RFC, we should probably re-implement github.com/php/php-src/commit/… as that was part of the point of the RFC...
 
10:11 PM
@MadaraUchiha in practice it's actually not that bad…
 
@bwoebi Of course it is, it's impossible to tell from the code whether a string is there because it's a string or because it's a callable
Not to mention the possibility of computer strings being treated as callables
 
@MadaraUchiha it is usually pretty obvious thanks to namespacing (backslash) or the string being equivalent to a std lib function
 
@bwoebi In most cases however I don't pass an stdlib function
I pass my own
And namespacing can definitely be moot especially if I'm defining the function and using it in the same namespace.
 
@MadaraUchiha then ti will be namespaced
@MadaraUchiha uhhh …
 
What? Do you put all of your functions into some util file somewhere?
 
10:23 PM
@MadaraUchiha Yeah, not using a FQCN for string function names is a really bad idea
 
@bwoebi Making users use strings as function identifiers for the past who-knows-how-many-years is a really bad idea.
Even Java doesn't do that.
I mean, come on.
Don't try to sell this clear design flaw as if it's somehow redeemable. I come from languages with functions as first class objects...
 
@MadaraUchiha I don't disagree
 
Using a FQCN is not a good solution
 
I'm just saying, that, as long as you use FQNs für functions, it is not very problematic in practice.
 
function myFilter($x) { /* ... */ }

array_filter('/uber/long/namespace/myFilter');
Really? :/
 
10:26 PM
@MadaraUchiha that's where you typically use short closures
 
@bwoebi No, that's where I typically pass in the function.
The idea of anonymous functions, followed by short closures, is to avoid boilerplate
   $x => fn($x)
// ^^^^^^  ^^^^ boilerplate
Don't get me wrong
I understand both the technical and political difficulties here
But these workarounds and cheap tricks are just not "it".
 
Umm … well, it's a whole debate, whether parameter naming of short closures is boilerplate or helpful information…
 
@bwoebi It's not helpful when I just delegate to another function call...
Now, it's not that JavaScript's model is perfect, not by a long shot
 
@MadaraUchiha that sure isn't.
 
(See [10, 10, 10, 10, 10].map(parseInt) in your console for a nice demonstration of where it fails)
 
10:32 PM
but more often than not, you do another manipulation than delegating on top of that
 
But I still maintain that it's superior to PHP's in almost every aspect.
@bwoebi Actually, it's the other way around.
You almost always already have a function ready for what you want to map/filter/reduce against
 
I then have a different experience…
 
And if you don't, you implement it inline in what you call the short closure.
 
@MadaraUchiha I can't agree on that…
 
.sort((a, b) => a > b ? 1 : -1)
.filter(isNaN)
etc
@bwoebi If you're doing lots of operations on your map/filter/reduce operations, you're kinda missing the point
The idea is to do small and short (and provable) operations on your data
 
10:34 PM
@MadaraUchiha I prefer not doing tons of microfilter/map ops
I find that more difficult to read actually
 
@bwoebi Then make the engine optimize them for you
Like Java does it
@bwoebi What, dataArr.filter(something).map(somethingElse) is less readable to you than dataArr.map(datum => { if (something(datum) { return somethingElse(datum); } });?
(ignore the oneliner)
 
@MadaraUchiha (except that there's a null returned?)
also, yes.
 
@bwoebi Yeah, except for that :P
@bwoebi Then functional programming isn't for you, because that's not really it.
This is really the base principle for fp, for better or worse
 
@MadaraUchiha uhhh … even in Haskell I prefer passing a closure doing all the ops instead of concatenating mapping ops
 
@bwoebi When I work with a high level language, I don't want to deal or think about how many ops my code will generate
 
10:38 PM
@MadaraUchiha I mean expressions
not byte code ops or such
 
In Haskell it makes even less sense given how most (all?) of the data structures there are lazy
 
@MadaraUchiha I just find it easier to read
 
If you have a mapping behind a filter behind a mapping, and one of the map operations are intensive, you want the filter to be able to run before it to save performance
 
@MadaraUchiha sure, you can do that in a closure too
 
11:13 PM
ugh, implementing enums is a pain no matter how
so making classes is actually really easy!
however… making classes with methods is, harder
either I have to synthesise user functions in the compiler (and it'll have to be in that file; Zend prevents anything except its compiler doing compiling), or do some sort of abomination with zend_internal_function with its own garbage collection
…or implement __callStatic I suppose.
I should maybe just do that, but Reflection users would be upset at me :D
 
@Andrea I have told you this class thing will be messy…
 
@bwoebi yeeeeep
Oh wait.
I figured out how to do it cleanly.
I was already thinking all enums might extend an abstract Enum class
implement __callStatic on that and all is well.
 
> Reflection users would be upset at me
 
true :D
also oh crap __construct is a thing
 
that's not cleanly then ^^
 
11:20 PM
@bwoebi it's cleaner than the other nonsense I'd have to pull…
 
@Andrea users will ultimately judge your feature by the exposed semantics, not the internal code…
 
@bwoebi mm.
I'm going to hate this but I think the most sensible thing is going to have to be some internal function hijinks
…argh, but garbage collection!
okay oh well user functions it is then
…but wait, internal modules!
 
I'm looking forward to you using trampolines.
 
…__callStatic. let's… let's just use __callStatic. what could go wrong.
hey I can always introduce ReflectionEnum right
(the actual problem with __callStatic though is it's really slow. and then it's even slower in practice because PHP handles case-sensitivity weirdly.)
oh I know how to do this… wait no but reflection argh
 
11:34 PM
ah I think I know how to do this efficiently-ish
oh no PHP has fake closures
what was that for, I can't even remember now
 
@Andrea closures returned by reflection from actual methods
 
@bwoebi ahhh right Reflection already had that before my closure reference adventures
 
right, and fake closures are just a flag to prevent weird binding to actual class methods
 
ahhh, that's it
$ sapi/cli/php -r 'enum Foo { Apples, Grapes, Parsely } try { Foo::Apples(); } catch (Error $e) {} Foo::Apples();'
frick yea, process startup!
lol
lol

Fatal error: Uncaught Error: Call to undefined method Foo::Apples() in Command line code:1
debug code is fun
also hey there @ircmaxell how are things
 
11:48 PM
Oh right, abstract classes can have constructors!
Ah, this makes it so much easier…
 
@Andrea sure
you just can't new them…
 
@bwoebi yep
so, the internal implementation of this should actually be quite clean
not particularly efficient, but clean.
aside from ignoring ZEND_ACC_STATIC if ZEND_ACC_ENUM is set ^^'
 
00:00 - 19:0019:00 - 00:00

« first day (2416 days earlier)      last day (2526 days later) »