« first day (2779 days earlier)      last day (2160 days later) » 
00:00 - 20:0020:00 - 00:00

12:01 AM
I bet I can tell you what you did wrong
I'll even give you a choice between a sarcastic answer and a serious answer for a small extra charge
@Wes yup. except when you want to provide extensibility with a default impl, which seems to happen a lot.
I'm pretty certain that ^ is the root cause of every interface naming issue I have ever had
 
Wes
same
when that happens though interface gets the pretty name, class gets the shitty name, it's usually DefaultFoo implements Foo
or StandardFoo
 
12:18 AM
@Wes yes, although it sometimes turns into a crappy decision again when said default impl has a public ctor, or when there are multiple provided implementations and a base class (BaseFoo also makes my face twitch)
internal visibility is one of my most desired features, but I have never yet come up with/seen a proposal of how that would actually work that I don't hate
I have reached the conclusion the lack of a native package-like construct/clear package boundary that the engine can understand makes it basically impossible to have something that is both useful and well defined :-/
 
Wes
i had one but you guys mocked me
 
I don't know if "mocked" is fair, but I probably didn't like it
typically they involve limiting access to the the current NS and it's children
which to me is just not useful, because generally you want to access internal members of classes in child NS as well
and some construct like internal(Root\NS) or whatever would be horrid, method signatures would overflow 80 chars before you even specified args
 
Wes
class Foo
{
    public function abc(private MyCollaborator $collaborator){
        // means requires private access to the MyCollaborator object
        $collaborator->privateMethod();
    }
}

class MyCollaborator
{
    function test(Foo $foo){
        $foo->abc(private $this); // means it gives private access to $this object
    }

    private function privateMethod(){}
}
 
I don't recall ever seeing that, gut reaction is that I'm not a fan of it because it feels like an IoC violation
i.e. MyCollaborator should specify that Foo is allowed to manipulate it's non-public members
 
Wes
it's two ways
the dependee (?) must ask for private access, and the dependency must give private access
$foo->abc(private $this); this line
 
12:31 AM
I'd rather something like class Thing friendof OtherThing but that feels crappy as well
the only thing I have seen that I don't entirely hate is a package declaration (with identical semantics to namespace), but I don't like having yet more leading crap at the top of the file.
I suppose you could do something like namespace [Package\Root]\Sub\Ns or namespace Package\Root:Sub\Ns
but I definitely feel that it should behave as public within a defined scope, and private outside it, with no pissing about with declaring relationships between individual scopes
eh, whatever, this is firmly in my "unresolvable" box :-P
 
Wes
my current position is: wrapping classes that hide some members are still the better option :B
i mean
A<->B share "private" data
then i wrap A into C and A is never accessed except from within C or B
C doesn't expose all methods that A has
 
@Wes I irrationally hate that, for the almost entirely invalid reason that the fcall overhead in PHP is large, even though I know it's a completely irrelevant definition of "large"
 
Wes
it is annoying as hell yes
and no you are right, function call overhead is still massive
 
Also it results in a lot of boilerplate, which is a much better argument against it :-P
 
Wes
also
 
12:44 AM
@Wes yeh in the 99% case you are talking about microseconds of overhead for a typical HTTP request
I could get behind some sort of class FooWrapper decorates Foo { public fooMethod, otherFooMethod; } maybe
 
Wes
do you remember i tried to propose that thing?
 
@DaveRandom I'm totally open to the idea of paying for some consulting.. :)
 
which is basically just sugar for a class with a 1 arg ctor that forwards calls to those named methods
@Wes vaguely
 
Wes
but you were all like no please lets get delegate types :B
delegate functions or whatever they are called in c#. i don't even know
 
@Darius was (mostly) joking about that, if you post some code and/or description I'd be happy to give you some opinions
@Wes that's a totally different thing though, not really related to proxy classes in any way other than that one might use the word "delegate" when describing both of them
 
Wes
12:49 AM
class FooWrapper implements Foo{
    public Foo $wrappee implements Foo;
    function __construct(){  $this->wrappee = new FooThatHasDangerousPublicMethods(); }
}
public Foo $wrappee implements Foo; this means that all methods in interface Foo and only the methods in the interface Foo must be delegated to $wrappee
 
I don't hate it
 
Wes
can do proxies, wrappers, facades, adapters
 
more flexible than my suggestion and potentially v useful for composition
 
Wes
anything... i mean, not just decorators (as in extend) you can also make an interface smaller
 
Trying out inheritance table stuff. I have a an abstract class "Media" and entity classes "Photo" and "PDF" + others for arguments sake. They each extend Media class. Right now, I have the saving and retrieving working great. Where I'm stuck now is I need store multiple versions of each file and not sure how I should store them and keep track of uploads. Photo needs 4 versions lets say (thumb, medium, large, original), PDF needs 2 versions (altered, original).
 
Wes
12:52 AM
like in that case you pick only the methods of Foo and hide the other methods that are not in Foo that are in FooThatHasDangerousPublicMethods
 
btw I assume the type decl in public Foo $wrappee is a typo?
otherwise seems redundant
 
Wes
that would be the type declaration
 
user2411267
guys any idea why json serialization ignores spaces in start of a string ?
 
is the any case where you would have public Bar $wrappee implements Foo;?
 
Wes
the type declaration could differ in future if we get generics
 
12:53 AM
I'm stuck with a chicken or the egg situation, where uploads are done prior to having a "photo" or "pdf" entity inserted. So I'm thinking I should have a "uploads" table, and a "uploads_versions" table.
 
@Ali.B it doesn't, you did something wrong/are not reading the output correctly
 
but then.. how do I reference what files get attached to Photo or PDF.. :\
 
Wes
well maybe you want to use Bar internally, and expose only the methods of Foo
 
user2411267
I checked output is correct, json convert is returning a trimmed string
 
I'm going to guess you are outputing it in a document that is being rendered as HTML and the browser is contracting the leading whitespace to a single space
that's just a guess though
 
user2411267
12:55 AM
yup I missed that
 
user2411267
ty
 
my clairvoyance is working well this evening
 
user2411267
lol
 
@Darius The key issue here is: what common functionality do the different media subtypes have?
i.e. what does that abstract class do
does it have any public methods and if so, what are they?
 
Wes
i'm still listening to wiki wiki wa wa
mostly because youtube is slow to load and that's a song i loaded :B
stupid internet
 
12:59 AM
So if you can , help me through the thought process, am I right in thinking "Upload File" -> I know which type this will be, so put into "uploads", generates an ID and puts in the filetype and account_id, and return ID to browser, when browser presses submit to add the Photo (extended media) entity, it will reference the upload ID, ownership and the filetype. It will create the versions of the upload , and insert into upload_versions, then it will create a ManyToMany relationship with
media ID and upload_versions
 
can you gist the public API? (i.e. something like this showing your actual API)
 
I'm assuming I'm doing it correctly by setting all methods to private in SF4. They all share, title, description, slug, category, user_id and some other things.
Yep, give me a moment.
 
I feel an interface segregation issue coming on
 
Yep, that's why I'm open to "consulting" :D I don't know the issues that will come down the line due to inexperience with this. I had them all as separate tables before.
 
@DaveRandom aImageSpecificMethod() :/
 
1:04 AM
mmm, delicious copypasta
 
:D
 
@Wes feels like a separate issue though, i.e. something that should be worried about only if/when enforced-type properties are a thing
...i.e. not something that you should include in a proposal :-P
I feel like that's the main reason I often disagree with your proposals, you try to do too much at once and create weird inconsistencies in doing so :-P
 
@Darius (Although I will go to pillory for this :P ) check Laravel Eloquent's polymorphic relationship.
 
here's a start, without all the upload stuff, since I haven't figured it out yet.
Kk. I'll take a look, at quick glance it seems they spread out stuff and make a lot of empty columns to reference like photo_id, art_id, pdf_id into one table.
I was hoping/thinking there'd be a way to do upload_id, item_id, entity_type and be better than having upload_id, photo_id, art_id, pdf_id.
 
1:15 AM
oh, doctrine
tbh I wouldn't worry too much about getting a fantasically awesome and beautifully perfect OOP relationship when dealing with database entities, especially in combination with an ORM, there will always be holes in it
 
Wes
@DaveRandom sure i wouldn't introduce in the proposal... problem is, as we are introducing a new syntax... must work with current syntax and probable future ones :P
 
Translate that to lay-man terminology?
Separate out the uploads tables for each specific type or go with laravel's method for polymorphic relations?
and yeah, already found myself annoyed with Doctrine's OneToOne relations... it eager loads them regardless of what you ask. :(
 
@Darius semantically in the database, what's the difference between the different file types?
a table for image uploads and a table for pdf uploads (or whatever) doesn't feel like the right approach, unless they have different metadata stored with them
 
Video model has few properties more than Image. Probably similar difference for Pdf too. As presented.
 
Wes
i was missing so much... it's always sunny in philadelphia is cracking me up
 
1:24 AM
@Darius Is meant to be very demanding for searches or more like "get by ID".
 
Of the few, only videos has a "converted" tag, only photos will have "width" and "height".
 
bearing in mind that I don't do orms: all files have a common shared set of properties, so it'd reasonable to store all that data in a common files table. If a specific type of file has additional fields, I might deal with that by having a videos table with that extra data with an FK to files
when translating that to classes, File has the properties from the files table and Video extends File with the additional properties
because orm/data mappers/whatever that abstraction might leak a bit
 
evening
 
Trying to wrap my head around what you said, you said it clearly, just trying to process it.
 
I think my American ears might be broken, I'm starting to discern the differences between British accents...
 
1:33 AM
@DaveRandom Thinking I understood what you said, what I came up with is for lets say photos I will have Photos extends Media, and Photos has extra columns for small_filepath, medium_filepath, large_filepath , and not reference to yet another table. And Videos will have extra columns for converted, sd_path, hd_path, 4k_path.
That way they all share Media , but have their own independent fields, without worrying of different types being in yet another table?
 
Good night people.
 
Good night Tpojka
 
Wes
after so many years i'm still not sure if i'm handling http errors correctly. i changed so many times and still not sure what's the best way to go
ultimately i don't care enough about it to improve the situation :B
 
Lol, our convo that got out of hand earlier this week about http errors.
 
Wes
i mean displaying error pages when something failed in the application
 
 
5 hours later…
6:09 AM
Still playing with class inheritance and table inheritance, trying to learn the correct way to use them. Is "Likes" a good candidate? Photo, Video have "likes" and I'll want to load up "all likes" at some point by a user, and also individually "video likes" and "photo likes".
 
6:38 AM
How can I affect on an outer variable inside a function? the expected result is 2
 
that's not nice
 
Why? It's actually a concept named "calling by reference"
 
6:55 AM
Am I weird for wanting to define my form validators as classes? It seems like there doesn't exist a good library to do this. At the very least none that were designed this way. I do know I don't want six billion rules wedged into my controller, and there is no way I can instantiate a validator outside of my controller without making a mess of my beautiful dependency injection.

Its possibly I completely don't understand what I'm doing. Not sure what the best-practice technique is here.
 
7:30 AM
Also, before I get my ears burned off, I am knowingly breaking the MVC conventions. Infact, I shouldn't really call it a controller. I'll just call it the thingy that talks to the ORM and Template.
 
@GiantCowFilms no that's just good oop. forget about mvc
controllers are only there to map the request from a medium (http, cli, ...) to your application. they should only contain code that is relevant to their medium.
 
@Patrick Should they handle the inverse mapping (application to medium). It seems form what I've been reading they shouldn't.
 
@GiantCowFilms I have tried to go that way, but it was always way overengineered. Since the controllers are only glue code, they only have very little code in them anyway. Splitting that up into two separate classes doesn't make much sense in my opinion
 
Proper MVC already seems overengieered.
 
There is no proper MVC on the backend of a web application
MVC is a frontend pattern
 
7:41 AM
Well, then Whatever proper MVC means in the context of a PHP application.
Half the battle is not butchering terminology.
 
Most people just use a normal layered architecture these days
 
What would that look like roughly?
Is it what you describe in your book?
 
Presentation Layer (Controllers, Templates, etc)
Application Layer (Commands and Queries or Application Services, the use cases of your application)
Domain Layer (Entities and other domain objects that encode business rules)
Infrastructure Layer (Implementations of interfaces that deal with external systems like talking to a database. DbalFooRepository for example)
@GiantCowFilms yes, it's pretty much this but I use the layer names from domain driven design instead
But it's pretty much the same
 
The entire thing on Domain Layer is just jargon overload.
 
Also if you need a new book to read, uncle bob just published a new one where he goes in depth on this amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/…
@GiantCowFilms it's pretty simple if you get to the bottom of it
 
7:55 AM
Okay, I think I am starting to get my head around the layered acrchitecture. Seems vaguely over-engineered to me, but that is more of a prefernce thing.
Still, I am disturbed by the lack if injection friendly validator libraries.
 
@Wes you can use it
I recentlyish made some changes so that it works on 7+
 
@GiantCowFilms If you work on a large enough application together with a number of developers, it makes a lot of sense
If you are the only dev working on a small webapp, it might seem like overengineering
There is no one size fits all architecture
 
@Patrick Makes sense
 
@Wes It basically boils down to Template::render($partialTemplate, ...$vars) { require $this->templatePath . $partialTemplate; }
 
8:10 AM
@GiantCowFilms proper MVC is what you do in large applications (think: 20k lines as the very least), because you need to impose restrictions on the codebase in order for it not to devolve in a garbage fire
 
Okay. I feel the need for a good simple application structure guideline.
 
you should not use any of the "named architectures" , if what you are building is a glorified guestbook
 
@NikiC regarding gc_data and gc_count, if I have a buffer of structs where the zval is the first member of the struct, can I simply use (zval *) buffer for gc_data? And is gc_count the number of slots in the buffer from 0 to consider?
 
You need some kind of an architecture though. Unless you want to do your routing with the filesystem.
 
@GiantCowFilms no, what you need is a routing library
 
8:15 AM
@tereško So what would you have it look like then.
 
having one does not in any way imply architecture
 
Fair enough.
 
@GiantCowFilms hell, you can make the routing-code yourself, it's not that hard: stackoverflow.com/a/19309893/727208
 
I've been using symfony's router on this latest project (a replacement for a file system routed site that has been left in production far, far to long).
 
 
1 hour later…
9:22 AM
@rtheunissen unless you have consecutive zvals, you can't directly return it
That is if you have anything else after the zval in the struct
if it's only a single zval you can return it with a count of 1
 
 
2 hours later…
11:40 AM
Hi, for those who want to take a look here:
https://stackoverflow.com/questions/50542302/merge-records-containing-the-same-keys-in-relation-to-another-table
 
11:53 AM
sure, have a free downvote and closevote
 
12:24 PM
@tereško it is really sad to read it from those who do not argue why, and above all do not know the solution to the problem.
 
wat
 
You gave a negative vote to the discussion, but do you know the solution to the problem? If you do not know why you give a negative vote?
 
WAT?
 
"sure, have a free downvote and closevote"
did you write it to me?
 
yes, because you spammed in a chat a post, that you had made 30 seconds ago
this chat is NOT for spamming links to your questions
and you "question" makes no sense, hence why it is voted to be closed as "unclear what you're asking"
 
12:30 PM
And why not just explain the rules instead of indicating that you give me negative votes for no reason? If you had told me I would have deleted the message from this chat, instead you gave me a negative vote, which should represent the integrity of the application, not the user's behavior.
@tereško But how does it make no sense? I entered the procedure, the query and the results of the extraction. I have also published the results of the query. I do not understand why it would not make sense ...
 
1:20 PM
I think i understood your question, it's a little awkward.. but.. just do two left joins.. twice on the seller
or twice on the code.. not really understanding what you're trying to accomplish, but that should get you your result.
 
Wes
@PeeHaa verstappen crashed again tho
 
1:32 PM
that's a 500k+ user
 
@Darius Thanks but I did not understand: I can not double LEFT JOIN of the same table, it always generates an error, can you be more specific?
@Darius and where it does not generate errors, the result does not change
 
Go back to basics, there should be no errors with left joins. Only null values if no results exist. That's as much as I can help.
 
@Darius Thak you
 
@tereško That's pretty wild. And his website/blog uses flash x_x
 
2:24 PM
Morning everyone!
 
Wes
@tereško it's the router that invokes controller and view?
$route = $router->route($request);
$controller->invoke($route, ... );
$view->invoke($route, ... );
or is it the handler of the router that should do that
i think i tried them both and i have no preference... i always keep stuff as simple as possible because i don't care enough :B
but i'm gonna publish this stuff on github and i don't want to be yelled at
also, did you try not building the view in the controller? that's a thing i like... but requires "application services"
 
So catching my PDOException but if I want to run var_dump for debugging and prevent my db credentials from being read out is this a viable approach: `public function __debugInfo()
{
$properties = get_object_vars($this);
unset($properties['host']);
unset($properties['user']);
unset($properties['pass']);

return $properties;
}`
 
Wes
don't override __debugInfo pls :B
unless you are adding information to it... just don't remove information
adding like return (array)$this + ["my" => "additional info"];
 
So what can I do to keep the db creds from being read out by var_dump during testing?
So... I can create an empty array and then add what I want read out like:
public function __debugInfo()
{
$properties = [];
$properties[] = 'table';
$properties[] = 'queryString';

return $properties;
}
 
Wes
2:43 PM
why is that a concern? debug information should not be displayed to the user
 
I am just wondering if I bring in someone to work on some code and I have a development environment setup and I want to provide a class for running var_dump but still want to prevent the db creds of the dev db from being read out how I can accomplish.
 
@Wes neither really :P
the best case scenario is to have a separate "dispatcher", that does the invoking
in some libraries the responsibility of disaptcher is merged into the router (example: FastRoute)
neither controller nor the view should have any clue about the existence of a router
closest you could get to that awareness of a routing code would be in some utility functions in the templating code (or extension, if you use Twig), that share the configuration with the router to let you generate URL based on named routes
 
Wes
$route is just an identifier with a map of data... or something like that. with that i invoke the relative controller
 
"route" is a part of HTTP abstraction
 
Wes
like, $controllers->get($route->getIdentifier())->invoke($route->getAction(), $request) or something
 
2:57 PM
wat
 
Wes
"$controllers" is a container
 
yu have too many arrows there
 
Wes
eh i know
 
So what do we call Plain old PHP objects?
 
the "invocation" is in no way related to the route - even in your code: you are just pulling out a parameter out of the routing's "result"
 
2:59 PM
POPO?
As in Mr. Popo?
 
Wes
it's not necessarily yeah
the controllers are not aware of the route
 
32 mins ago, by Wes
$route = $router->route($request);
$controller->invoke($route, ... );
$view->invoke($route, ... );
 
Wes
the $route though is just a map of data (minimal data) with a name
just an example... i never do the same thing
 
why would you need a name?
 
Wes
the name is used to figure out the controller and view class
 
3:01 PM
a named route is only necessary in the templating .. and only if you rally need it for generating URLs (and it would not really be related to the name of "current route")
 
Wes
the "map of data" is used to figure out the action
hm
 
the names of controllers or views should not have any different status than name of the "action"
routing code does not care about the business app
it is a separate layer
 
Wes
makes sense yeah
do you use a DiC to instantiate controllers and views?
 
Wes
like auryn?
 
3:05 PM
 
Wes
$controller = $container->get('controller.' . $request->get('resource'));
$controller->{$command}($request);
$view = $container->get('view.' . $request->get('resource'));
$response = $view->{$command}($request) ?? new Response;
 
but it would be pretty much the same in Auryn
 
Wes
that's pretty much what i do, except that i use also $route rather than just $request
also similarly the controller has no knowledge of the view... i thought you didn't like that?
anyway ok... trying with that
ty
 
How much rep did Your Common Sense have before his suspension? Anyone know?
 
Your Common Sense is suspended?
 
3:21 PM
Has been since Mar 31st.
Check out his comments under his account - one second
That one is his profile
 
Wes
@2dsharp we are using php, so yes. our common sense is suspended
 
Very true.
 
Why do we bag on php so much yet use it?
 
3:34 PM
@StatikStasis That's not page 1, that's the page after they are done explaining how to use mysql_ functions in a "secure" way.
 
@Darius Make fun of ourselves so that it doesn't hurt as much when others do it. =)
 
@StatikStasis you have been working on Jeeves, right?
 
Wes
@Darius we joke. php is not really worse than other languages
we are only honest about it :B
 
@2dsharp Not really... I merely added two questions and answers to $patterns.
 
I personally like this one:
 
3:39 PM
I'm trying to find the one I saw yesterday. It was the one where there is a kid in a hospital bed hooked to a machine with his parent. The kid says something like "Now that I am getting healthy, I want to be a PHP Programmer. The next strip shows the parent with tears in their eyes unplugging the machine keeping them alive.
 
Tom
@Darius because we would rag on Perl but not enough people use it anymore to ensure a good target to slag at :P
 
Wes
 
Tom
Full disclosure: I have to write Perl at work when dealing with older systems so I have plenty of experience >.<
 
@Tom s/experience/trauma
 
Wes
lol
 
3:45 PM
@Danack did they reach out to you?
 
user image
9
There it is
 
Wes
that's cruel :B
 
So is being a php developer.
 
Wes
4:30 PM
@tereško if a view must respond with a 500, how would it do that?
 
send a header in the response, with 500th status code
I assume you are not confusing "view" and "template"
 
Wes
:B yes
i am overthinking about it probably
 
5:01 PM
how do I echo a variable value early in page while assigning the intended values later in the page?
2
Q: Can i declare a variable and assign a value later?

Marcocan i declare a variable and assign a value later ? Is this feasable somehow ? $redirect = "recording.php?album=$albumid"; $albumid = 4;

the solution here is not doing any good for me
I am echoing the value so I think that might be the case.
 
5:24 PM
wa
@azamkhan the big question is "why?"
what problem are you trying to solve?
 
5:38 PM
Though now i have fixed it. but let me explain the problem..
i am retrieving comments and want to store the last comment id for on scroll retrieval.
I had the logic later in the page where I store the id as attribute on the div element. Now I have had to move the div to the top of the page and the foreach statement where I retrieve the comments is now later in the page and the lastid is populated there.
Though now I have retrieved the last comment id based on the size of the array and retrieving the last id.
@tereško
 
a? (reading)
 
@azamkhan actually the proper solution would be: stop echoing parts of the page
you should start using a templating engine \
either something of "enterprise grade" as Twig
 
okay.. which one
is laravel etc template engine or else
I think that is a framework
 
Twig is a stand-alone thing
 
5:43 PM
what is bad with echo anyway
 
hmm ... the biggest reason?
you can't redirect in the middle (you will get a "header already sent" error
 
?
explain the last part
 
sorry .. I am already half-in on a bottle of wine
 
I use ob_start for theat
 
yeah, that's a hack
 
5:45 PM
can i use the same for the echo
 
ok, you get the "header already sent" error, if php has already started sending response body (content)
at that point you cant send anymore any headers (and redirects are actually only one of them)
you also cant send expire headers and content-type headers
all sorts of useful things
also, having echo all over your code make a lot of "noise"
 
oh dear all this time I was thinking I doing something wrong..
 
well .. you were :P
 
what if I switch to laravel .. should I be learning something like twig
then
 
fuck laravel
 
5:48 PM
oh
 
read the article I linked you to - it will explain the basics of templating, it's usually enough for simple sites
 
what is wrong with that
 
@azamkhan if you mean "what's wrong with laravel": chat.stackoverflow.com/…
let's put it this way, it's the fox news RT of the php frameworks
ans for templating, the "simple php templates" is the ... emm ... common approach
\and the Twig is as close as "industry standard" as php tends to get
 
@Wes right, I have to send that email to StackExchange
 
Wes
5:54 PM
i am basically ignoring any gdpr email i am getting. am i doing the right thing?
 
@Wes not entirely
129
Q: We're examining the implementation of arbitration in the 2018 ToS update

Tim PostThis is an addendum to our announcement about a recent ToS update concerning Stack Overflow For Teams and GDPR; I'm starting a separate discussion because concerns about the third bullet, an introduction of an arbitration clause, has caused consternation to rise to a level that we quite frankly d...

-255
Q: A new (2018) update to our Terms of Service is here

Tim PostBut not just because it's 2018, although that's a fine reason to do a great number of things. We're changing our Terms Of Service (ToS) shortly to address three things: Stack Overflow For Teams is launching soon, and we need to include stuff that talks about us expecting people to pay for it, ...

there has been issues
and this is a community that is tech-savvy
also, you are probably getting a lot of "we bought an email database and we are checking which of these emails are actually used" spam (depending on implementation of gmail proxyies, they might be actually tracking the "opening of emails" based on unique embeded image lins)
@Wes the whole thing is a shitstorm that very few are even aware of
 
Wes
tried to read this the other day (i probably should...) ec.europa.eu/info/law/law-topic/data-protection/reform/… but got lost in legalese
 
6:11 PM
@teresko so you mean I should not use a framework
 
@azamkhan there is no simple answer to that. Frameworks are a form of technical debt. You use them for a specific goal, IF you have a good understanding of the underlying assumptions.
usually that means a good grasp on OOP in general and various of its practices and principles (SOLID, LoD, SoC, etc.)
 
6:26 PM
wtf imgur won't let me ctrl-v from the front page anymore
 
6:45 PM
@NikiC so in the case of the ds htable bucket, which has 2 zvals each, what do I do with gc_data? Do I need to do an allocation of that pointer in that handler? And then in the case of the priority queue which has {zval, int}, I can't set *gc_data to anything directly because there aren't consecutive zvals.
 
@rtheunissen If you have 2 zvals each just return the buffer and 2* the size
for zval+int you'll have to allocate a buffer
The usual pattern is that you add an extra field to the object with the buffer
 
And the ZVAL_COPY_VALUE into that buffer?
 
you can see this in some spl classes
yeah
it's somewhat ugly because the buffer will stay allocated until the object is destroyed
but right now there isn't really a better way
 
I've seen that, but doesn't that mean that you have an entire allocated buffer on the object that doesn't serve a purpose other than to tell the engine what to gc?
Haha yeah exactly what I was trying to say :p
If I allocate the gc_data buffer itself, will that get freed later on?
 
nope, you'll have to free it yourself
 
6:48 PM
I'm guessing no.
Yup cool.
 
that's why you need to store it on the object
we should add an is_temp flag to indicate that GC should free it...
 
That'd be nice. So that it can use it and discard it when it's done.
 
though also not great, because that buffer is needed multiple times during GC
 
So that handler is called when the object is garbage collected, right?
So that memory is potentially freed very shortly after it's allocated?
 
which handler?
 
6:50 PM
the get_gc
I free what I store on the object for that in free_object
So.. allocate in get_gc, free in free_object
 
yeah
and ideally try to lay out data structures so you don't need to :D
like your map example
@rtheunissen for the pq, you're already using the u2 value?
 
I'm trying to get around that int for the priority in the pq
 
what's it for?
 
Yeah I'm using it for an insertion stamp to preserve LIFO for equal priorities
But there must be a way to construct the heap so that LIFO is preserved without that stamp.
I just haven't sat down with my notebook to sketch it out yet.
 
I don't think there is
 
6:53 PM
u2 would be perfect for the priority (albeit 32 bit)
 
@rtheunissen another approach would be to ditch the priority and have a comparator instead, but I guess in PHP that would be rather slow
@rtheunissen though actually I think that might be a good idea
as you don't expose a proper heap structure, only a pq
While for any of my recent uses of heaps I did not have a meaningful (especially integer) priority handy
 
Yeah I had in mind having a priority queue as it stands now. but also a heap with a comparator.
One of the textbook examples where a pq is used is Dijkstra's algorithm, but that requires you to change the priority for a specific value, and doesn't support duplicate values. I think you can just use the ds map for that though, except you wouldn't know the lowest value until you sort the map.
Would be O(n) to change the priority of a value in the ds pq as it's done right now.
 
@rtheunissen even for dijkstras algorithm you're likely to need float priorities
@rtheunissen updating priority sounds pretty tricky
I think you'd have to combine a heap and a map to do that efficiently
well, "efficiently"
 
7:13 PM
o/
 
user1804599
7:44 PM
I need to chat more now that I have a keyboard that I would love to type on constantly.
 
00:00 - 20:0020:00 - 00:00

« first day (2779 days earlier)      last day (2160 days later) »