« first day (1687 days earlier)      last day (3255 days later) » 
00:00 - 18:0018:00 - 22:00

6:02 PM
*$r == 0
writing that more than... four times.... would kill me
@LeviMorrison Comparable was originally broken because did not use generics
but it does now
 
@Worf That took until Java 7...
 
yeah
 
Actually I'm wrong on that.
Both Comparable<T> and Comparator have been around since 1.2.
(I think that's the Java SE number; not sure which Java number that translates to)
 
6 major versions mistake
 
(maybe Java 2?)
 
6:06 PM
no idea :P
> To avoid the problem of asymmetry (“a.equals(b)” vs. “b.equals(a)”), we just have to match the type exactly instead of simply checking for compatibility using “instanceof”:
for polymorphism one could check if $this implements the same interfaces (no more no less) of $other
 
@LeviMorrison I would love to see generics in PHP. It would be nice to be able to make a interface like Comparable<T> or class Promise<T>.
 
@Trowski levi will eventually get there
 
It might be nice if we could somehow integrate async functions into PHP, sort of like what HHVM did. async function () : Awaitable { }
I thought this might require generics, since maybe we'd want Awaitable<T> instead of just Awaitable.
 
6:22 PM
Operator overloading is like goto. Very useful in extremely narrow and limited usecaaes. But 99% of the time they are a complication and a distraction. Buy unlike goto, you can do everything without overloaded operators. So no thanks...
2
@Trowski why not do it on call side, rather than declaration side...?
 
@ircmaxell That's essentially what Icicle does.
Maybe the performance gain from putting the scheduler in the engine wouldn't be as great as I think.
 
@NikiC no, I seriously don't consider that code to be acceptable… it actually looked worse than I thought it was going to be ^^ better now? ;-D
 
well, defining how == should behave is not the same as overloading the modulus operator :P
 
@Worf it is.
it maybe doesn't feel like the same, but it end up being the same.
 
It's odd that some of the built-in objects can be used with comparison operators, but you can implement that behavior in user land.
 
6:33 PM
also ^
looking forward to being able to properly implement $goat ** $spaghetti
 
I could take it or leave operator overloading though. I can see how it would be often used improperly.
 
@bwoebi yes ^^ though using "\0" for a not found cookie is an arguable decision ^^
 
@Worf Like that, lol
 
I hope this is not where not having nullable types will lead us ^^
 
@NikiC could have "", but "" is a valid cookie value ^^
 
6:35 PM
could just leave null and drop the typehint...
 
@NikiC argue that with @rdlowrey … Sometimes he just insists on his opinion…
 
user895378
Everyone insists on their own opinion
 
I'll happily revert that part though.
:-D
 
user895378
My preference is to return string and not string|null because there's value in a strict return type
 
@rdlowrey string|null is still a strict, specific return type…
It's always just null or string…
 
user895378
6:39 PM
@bwoebi a type that isn't verifiable by the compiler is not a strict, specific return type by any definition
 
user895378
That's a ridiculous statement
 
@rdlowrey that's just because PHP 7.0 doesn't support that yet, lol
 
user895378
If you want to differentiate between an empty cookie and a non-existent cookie value (ALMOST NO ONE EVER DOES) that's why hasCookie($name) exists.
 
……………
 
@rdlowrey There is value, yes. For example I can see the argument of strpos() returning -1 instead of false to have a consistent return type.
But this looks pretty clearly like you're trying to forcefully shoehorn something into the string type just for that precious type hint
 
user895378
6:41 PM
@NikiC And why not when you can explicitly state your intent with the method name?
 
user895378
getCookie(): string|null actually means "get cookie but only if it exists"
 
@NikiC stuff that was badly designed in some 1970 language and that was inherited by all modern languages imho
 
@rdlowrey If it's only supposed to be used for existing cookies, throw an exception
 
@rdlowrey No, it means "get cookie", not only if it exists.
 
user895378
@bwoebi which is an impossible operation when you return null
 
user895378
6:42 PM
And you can no longer verify correctness using typehints
 
user895378
And verifiable correctness has value
 
and like everything which has not a value, it's equivalent to null.
1 min ago, by NikiC
But this looks pretty clearly like you're trying to forcefully shoehorn something into the string type just for that precious type hint
 
user895378
That's exactly what I'm doing
 
user895378
Because there's value in the strict typehint and none from returning null
 
@rdlowrey I feel like you're not verifying correctness here, but are actively preventing verification of correctness
Because now you have the same return type for the success and the error case. Which means that code down the line will not break as it ought if somebody forgets to check the failure case
 
user895378
6:43 PM
I'm trying to avoid unnecessary breakage from strict type hints
 
user895378
I just see no additional value from returning string|null
 
@rdlowrey but not by force. That's the programmers responsibility. E.g. imagine a bug where all anon users get the same rights because there's accidentally a session named "".
 
user895378
Because you still have to check the value to determine existence
 
And if you don't consider it to be a failure case, then return either an empty string or have a parameter that's returned as fallback.
 
user895378
@NikiC which is exactly what I'm arguing for
 
6:45 PM
@rdlowrey You're returning "\0"
 
(no, that was me)
 
user895378
Bob is returning "\0" inexplicably
 
I can see the argument for an empty string if you want to have a model where a non-existing cookie and an empty cookie are strictly equivalent
 
Daniel wants to shoehorn it into a string and I want to be able to differ between a non-existing and an empty cookie without weird has-calls.
 
But a NUL byte is just weird and the person debugging this will go crazy with this useful, non-printable character
 
user895378
6:47 PM
hasCookie($name) is better and more explicit than isset(getCookie($name)) if you actually need to check for existence
 
@rdlowrey why?
 
user895378
Because it's readable and explicit
 
user895378
I can't believe I have to explain why
 
the latter is too.
 
user895378
No it's not
 
user895378
6:47 PM
It requires knowledge of the API
 
You can't write isset(getCookie()) anyway :P
 
user895378
isset() does not mean "cookie nonexistent in request"
 
(I think)
 
it's very intuitive
@NikiC no, you can't… you'll write getCookie($name) === null
 
user895378
@bwoebi Readability isn't about something being intuitive to someone who knows the language. It's about being explicit to someone who doesn't know anything about the problem domain.
 
6:49 PM
@rdlowrey null/nil/whatever is a very universal concept…
 
user895378
hasCookie() is far superior for readability. Returning an empty string from getCookie() on a nonexistent field is far superior for compilation type checking. It is a win on both fronts.
 
user895378
@bwoebi But it's not readable
 
user895378
hasCookie() tells you exactly what is meant
 
user895378
isset tells you whether or not a value is null..
 
user895378
There is no comparison.
 
6:50 PM
@rdlowrey what about an exception, if you're supposed to use hasCookie() for existence checks?
 
How does malloc guarantee alignment? Does it always just allocate extra space with maximum alignment of builtin types?
 
user895378
@NikiC You aren't supposed to though -- the logic is that you almost never need to differentiate between existence and an empty value.
 
@NikiC yeah, that's IMO the alternative… has + exception in getter… I just hate that approach because it always needs two method calls.
 
user895378
And if you do need to differentiate you still have to make another check either way when returning string|null
 
@rdlowrey I absolutely don't like the value being coerced into an empty string if it doesn't exist…
 
user895378
6:51 PM
@bwoebi Then return a string and throw
 
user895378
Because I absolutely don't like a mixed return type
 
@LeviMorrison Malloc likely can't manage memory at a granularity where alignment would even matter
 
user895378
But please do not return "\0" ... that is crazy
 
I'd assume that it aligns everything to 8 byte boundaries
 
@rdlowrey agree
 
6:53 PM
C11 has alignof and aligned_alloc. If only we could use them!
 
What do you need this for?
Are you ... vectorizing something?
 
Oh, I don't need it, per se.
I was just thinking about certain optimizations that would be easy to do if we could use these things.
 
@LeviMorrison We use a custom allocator anyway, so probably it wouldn't be much of a problem ;)
 
user895378
@bwoebi look, I can get on board for string|null but the API has to be consistent and currently the header functions use a typehint. So whichever way it goes the API has to be consistent
 
user895378
My point was simply that your cookie behavior differs from other behavior in the request API and that's not an option.
 
6:56 PM
@rdlowrey getHeader method returns an array
@rdlowrey can you please tell me quickly the difference between headers and headerLines?
 
user895378
Because a header is a compound type by definition -- it always returns an array -- an empty array means there weren't any headers of that field
 
@rdlowrey which is totally fine.
 
user895378
getHeaderLine() is simply using the same API as PSR-7
 
user895378
Because you can have headers like this:
 
user895378
GET / HTTP/1.0
My-Header: value1
My-Header: value2
 
user895378
6:58 PM
$request->getHeader("my-header") would return ["value1", "value2"]
 
user895378
$request->getHeaderLine("my-header") would return "value1, value2"
 
user895378
All HTTP headers are a compound data type
 
is that equivalent?
 
user895378
No. One is an array and one is a comma-concatenated string.
 
no, in HTTP protocol?
 
user895378
7:00 PM
HTTP doesn't know about arrays?
 
user895378
GET / HTTP/1.0
My-Header: value1
My-Header: value2
 
user895378
is equivalent to:
 
user895378
GET / HTTP/1.0
My-Header: value1, value2
 
I mean two headers vs. one header with comma separated values?
okay, that was my question
 
@rdlowrey So if this is the request, would $request->getHeader("my-header") on it return ["value1", "value2"]?
 
user895378
7:01 PM
@NikiC yes. I think this is ugly but I did it because that's what the god-awful PSR-7 prescribes.
 
@LeviMorrison thoughts about the "undefined" type?
class Vector{
    function set(int $offset, T $content) : T|undefined{
        if($offset <= $this->getLength()){
            $previous = $offset === $this->getLength() ? undefined : $this[$offset];
            $this->contents[$offset] = $content;
            return $previous;
        } throw new VectorIndexOutOfBounds;
    }
}
 
@rdlowrey lol, since when do you give a shit about PSR?
 
user895378
I don't, but I was trying to be nice since that's what all the framework users I hope will use my server will be familiar with.
 
@rdlowrey I'd rather have one uniform way for that
because:
 
user895378
IMO Message::getHeader(): string and Message::getHeaderArray(): array would be best
 
7:03 PM
GET / HTTP/1.0
My-Header: value1, value2
My-Header: value3
^ won't that get a bit messy? with getHeaders()?
 
user895378
Why would it?
 
Won't that end up as ["value1, value 2", "value3"] ?
 
user895378
Sure -- which is why getHeaderLine() is what most people should use
 
user895378
But IMO almost everyone expects to get a string back when they call getHeader()
 
@rdlowrey actually, most people will see, oh, that returns a pre-exploded string; nice, I'll use that.
 
user895378
7:04 PM
Which is why I think that should be the default and a getHeaderLines() should return an array
 
user895378
But PSR-7 ...
 
don't try to be weirdly half-compatible… that end up being worse than it already is :x
 
user895378
If we don't care about being compliant with PSR-7 (in fact, this would be the exact opposite of its recommendation and probably confuse people) then we can just do it correctly
 
I wish we'd just always get a nice comma exploded array back
 
user895378
Well that would require a lot more (slow) parsing than we currently do and for zero benefit in most cases
 
user895378
7:06 PM
In any case, you have access to the raw request trace if you want custom data structures.
 
@rdlowrey we're currently imploding the headers to get the header line… if we replaye that by exploding, everything is fine
also, it avoids us having two functions for the same thing
which IMO is bad.
 
user895378
I agree -- like I said, I only didn't it as an olive branch for people who want PSR7
 
@rdlowrey because nearly nobody knows that headers can have multiple values
 
user895378
Also: I think we're particularly well-positioned to just Request::getHeader(): string; because we also provide Request::getTrace()
 
user895378
This is in contrast to the web sapi where you can't access the raw request message
 
7:10 PM
I'm okay with Request::getHeader(): string|null;
 
user895378
fine.
 
Also, when I have changed that, may I merge cookies branch into wip?
 
user895378
No.
 
@rdlowrey Or anything else which needs discussion?
 
user895378
Just because there is a lot of untested code using the current request API.
 
user895378
7:11 PM
I'd prefer to do the merge myself
 
okay, then change that in Request::getCookie() to string|null too when merging. But please do the merge yourself now. then @rdlowrey
 
user895378
I will change it -- but I can't do the merge until later tonight :)
 
@rdlowrey you mean because workerwatcher? yeah, fine
 
user895378
Yes. Also it'll take some time -- there are a lot of places where code has to be updated ... websockets, static file handler, filters inside the main server, etc.
 
@rdlowrey I can do that too if you like to…
(not merge, but the commit)
 
user895378
7:16 PM
I still believe we need to keep Request::getHeaderLines($field): array
 
user895378
It costs nothing because we already have those from the parser and there are times when it's useful
 
@rdlowrey when does it help?
 
user895378
When you have to check the value of the connection header in a websocket handshake, for example
 
user895378
It's not correct to just explode a concatenated header on ","
 
user895378
Because headers can use quoted strings
 
user895378
7:18 PM
Unless you want to introduce real byte-by-byte header value parsing (which is very slow to do in php comparatively)
 
so, what will you do with something like:

Connection: "val, ue", value2
Connection: value3
@rdlowrey
 
user895378
Deny the handshake because those aren't valid values
 
user895378
foreach ($request->getHeaderArray("Connection")  as $value) {
    if (strcasecmp($value, "upgrade") === 0) {
        break;
    }
}
 
Protocols should have one, and only one, way of doing things.
 
user895378
I agree -- this is a major problem with the HTTP/1.1 protocol
 
user895378
7:22 PM
@bwoebi on second thought, we can just leave the array method out. Screw HTTP/1.1
 
user895378
We'll support HTTP/2 soon enough anyway
 
And case-insensitivity in protocols is horrible as well
The only thing it could possibly be good for is slowdown and inconsistent handling in implementations...
 
@rdlowrey haha
 
user895378
The problem is this:
 
user895378
GET / HTTP/1.1
Connection: upgrade-incorrect
Connection: keep-alive
 
7:23 PM
@rdlowrey I already started looking at RFC 7540…
 
user895378
nice
 
user895378
That message above is the problem with doing stripos($connectionHeader, "upgrade") !== false with a concatenated header :/ technically that's a bad connection header that we should fail in a websocket handshake
 
afk for a while… family time :-)
yeah, just always having arrays makes it easier, also with http 2
 
user895378
@bwoebi so you want getHeader($field): array, right?
 
user895378
(just so we're on the same page)
 
7:33 PM
Anyone else kinda follow the Filesystem Hierarchy Standard when naming folders in a project root?
bin -- bootstraps and phars
etc -- config
var -- local non-config data (xml, json, etc)
lib -- zee codez
Although, TBH, I'd prefer to use /src for zee codez, and /lib for composers /vendor
 
@rdlowrey yeah
@DanLugg @rdlowrey does AFAIK… and var is not needed IMO.
 
I deal with XML, so var ftw lol
Though I see how you'd say that
 
7:55 PM
@rdlowrey I prefer getHeader ($field) : string and getHeaderLines ($field) : array.
 
So, I swapped vendor to lib via the config/vendor-dir composer setting... Am I gonna fuck anything up royal doing this? As far as local or interop is concerned?
 
getHeader will return the first header line or "".
 
user895378
@kelunik This is the behavior I tend to expect as well
 
user895378
getHeader($field): array quickly becomes a hassle in real code
 
@DanLugg I've said this before, but I'd like a shadow class hierarchy to match the scalar types
 
user895378
7:57 PM
It's a total PITA to always be doing getHeader($field)[0]
 
So there's an actual class Integer (alias Int) that extends abstract class Number etc.
 
@rdlowrey Undefined index ... ;-)
 
user895378
that too
 
user895378
@kelunik the funny thing is this is the exact opposite of PSR-7 ;)
 
@rdlowrey PSR-7 sucks anyway.
 
user895378
7:59 PM
I've been working with HTTP for years and still this is an issue for me -- that should tell you how crap the protocol is
 
user895378
"protocol"
 
@DanLugg you ought to have your code in a separate directory from the composer installed stuff....It sounds like you're trying to force it all in one dir?
 
user895378
If there are multiple ways to do something it's not a "protocol" ... its a set of "suggestions"
 
Oh, it's no longer Friday. I can't troll people any more :(
 
@Danack No no, just renaming vendor to lib
Because because
@Andrea Integer implements Numberable
 
8:05 PM
@DanLugg something like that
 
"Can you add them together?" "I believe so, they're both Numberable"
 
though it's important to reflect reality
 
@rdlowrey yeah, I realize that too, the issue is just that you will get unexpected behavior when initially two headers were sent and you do explode("=", $header, 2) and have a comma in second part of explode etc.
 
PHP type hierarchy:

mixed
- NULL
- bool/boolean
- (abstract) numeric
  - int/integer
  - float/double
- string
- array
- object
  - <classes>
- resource
 
@Andrea just that string might be numeric too, but yes.
 
8:08 PM
No
String can be coerced to integer or float, but you can't really do any numerical operation on it directly
Aside from increment/decrement
If you actually made yourself a full class hierarchy with all necessary methods to represent the operators and functions PHP supports, I think you'd realise just how much of a complete mess PHP's types are
 
@Andrea Why should you be able to increment / decrement? I'd allow all operations or none.
 
I'm not talking about the theoretical optimum. I'm talking about PHP as it actually exists
 
Hi every body, I have a question: can we limit/control the scope of a variable in PHP, I have a reference created inside a loop, I want to limit the reference scope so that every time a new iteration starts I start again like it wasn't defined in the symbol table before
 
I don't like that you can do $a = "abc"; $a++;, but the fact remains that PHP permits this.
 
8:28 PM
@AbdoAdel yeah, then just overwrite the reference with a new reference?
 
yes but without affecting what the old reference is poiting to, liek what happens in c or c++ int* x;{int* ptr = new int; *ptr = 10;x = ptr}
after the }, there is no ptr but the value is still there
here is my case, for .... {$ref =& some assignment; $ref->change sth}, what happens is that every time the iterations starts, all the previously objects pointed to by $ref changes too
I want $ref to be destroyed after the '}' like in c, is this possible?
is the question confusing or unclear?
 
@AbdoAdel Use unset() to unset the reference at the end of the loop block
 
8:43 PM
(y)
 
8:56 PM
hi, how can i trace email sender's location?? is it possible or not please anyone tell me.
 
"it depends"
 
what depends @PeeHaa?
 
user895378
@bwoebi Yeah, that's what I was trying to say ...
 
user895378
But the point is it's terrible having to access an array index for every header
 
user895378
Like you said, nobody even knows that headers are multiple values
 
9:03 PM
it's the only sane way, I fear
 
user895378
So it makes the most sense
 
user895378
No, I promise this is the most sane way:
 
user895378
// returns the first header in the array
Request::getHeader(string $field): string|null

// Returns the array of headers (maybe empty) for this field
Request::getHeaderArray($field): array

Request::getAllHeaders(): array
 
user895378
Because most people never care about multiple headers
 
does Request::getAllHeaders depend on getallheaders?
 
user895378
9:04 PM
No -- getallheaders() has no applicability in the CLI
 
@rdlowrey okay, that's fine too.
 
user895378
@bwoebi that was the original plan then I tried to match the dumb psr7 api
 
user895378
should never have bothered with that ...
 
@rdlowrey yeah, the hype you can withstand…
 
user895378
getHeaderLine() is a weird name
 
9:06 PM
yes.
 
user895378
Especially considering a header is not a 1:1 ratio with a line:
 
What you just proposed here is just fine
 
user895378
GET / HTTP/1.1
Header1: text
\t\t\t\t\tmore
\t    more
Header1: another line!
 
@rdlowrey I thought we'd not support that one?
 
user895378
@bwoebi we're not -- i'm just trashing the PSR api :)
 
9:08 PM
hehehe
 
user895378
Because the word, "line" isn't appropriate when you're talking about headers
 
user895378
RFC 7230 does deprecate the use of \r\n\t as a continuation of the same header value but still ...
 
and anyway the header name itself is also part of the line…
 
\o/ I iz back
 
9:10 PM
For some reason le chat didn't load for me
For some reason le chat didn't load for me
Hmmmm /rooms also isn't loading for me :(
 
9:54 PM
@PeeHaa Working for me, still having issues?
 
Yes seems also to be working for me now
Tnx @DaveRandom! :P
 
I totally fixed it
 
That's why I love you
 
00:00 - 18:0018:00 - 22:00

« first day (1687 days earlier)      last day (3255 days later) »