« first day (1868 days earlier)      last day (3080 days later) » 

Abe
4:00 PM
constant arrays @NikiC ?
 
@Abe thx
 
@NikiC you can do class A{} $a = "A"; $foo = new $a[0](); right now, this is legal
 
Abe
@NikiC joking me? :P
 
@Abe ?
 
@nikita2206 er, I think we probably shouldn't support new $a<T>
that's really weird, you're having half of the class name not in the variable
 
Abe
4:01 PM
nvm, strange that you didn't guess why [] would be bad :D @NikiC
 
@Andrea But as @Abe said, things like Foo[X] are currently valid. You don't need to go to variables
 
@NikiC For constants, yeah
 
Abe
how hard would it be to have >> parsed as two characters instead, and treat it as shift right only when needed?
 
hmmmm
 
And {} has similar issues due to the absolutely stupid and pointless alternative syntax
 
4:02 PM
@Abe trivial, but then you can do 2 > > 2, eww
 
@Andrea I don't know, the hardest thing is if you have generics how can you instantiate generic class dynamically if you have classname and all its template specifiers in variables
 
@Andrea you could check against that ^^
 
@nikita2206 ["Foo", ["int"]]
@NikiC oh god the hackiness (but yes you could, good point)
 
Abe
@nikita2206 via reflection?
 
yeah
 
Abe
4:05 PM
in my lib it will be something like (new ReflectionProtoClass('GenericClass'))->parameterize(new ReflectionClass('Stuff'))->newInstance()
 
 
maybe we just don't instantiate generic classes
make them exist only as a type hint
(this is probably a terrible idea)
the issue that bugs me is that the parser will moan about Sequence<int>::someMethod(..., ...)
Hey, we could go full PHP...
 
Abe
wat, generic static methods don't exist
 
Sequence<:int:>::someMethod(...)
@Abe they should
 
Abe
not even static should exist :D
 
4:07 PM
@Andrea hm what's up with this?
 
@Andrea There should just be no generics for static methods.
 
what's the problem?
 
@nikita2206 it would be interpreted as Sequence < int and the parser will get upset
@kelunik Why not?
 
@Andrea well static method should be able to infer everything from the input
 
@Andrea Why should this definition be on the class? Generics are on specific objects, not in a class.
 
4:08 PM
@kelunik no, they're not
a generic class is a parameterised type
 
@Andrea oh no, it's the same as new Sequence<int> just one shift/reduce conflict more, raise %expect to 1 and it's fine
 
If you want it for the static method, use Sequence::someMethod<int>(..) ;-P
 
its type is incomplete unless you specify its prarameters
@nikita2206 lol
 
@Andrea yeah i know, that's how I made it to work right now
I mean, who the hell cares
 
An example:
Sequence<int>::fromArray([...])
Without generic static methods you can't have multiple constructors
 
4:10 PM
yeah, @kelunik is right, you specify generic parameters on method, not on a class in this case
 
why?
 
Abe
^
 
because it's method-wide
 
no, it's class-wide
 
the scope of this generic parameter is limited to the method
 
4:11 PM
If it would be class-wide, there's no reason to have it generic, then it's a set type.
 
this is the constructor of Sequence<int>. it constructs a Sequence<int>.
 
you can make it class-wide but it doesn't really make sense
 
@kelunik what?
 
public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
    return p1.getKey().equals(p2.getKey()) &&
           p1.getValue().equals(p2.getValue());
}
// this is in java ^
 
Generics are specific to an instance, so you just need it when creating a new instance. If you create the instance in a static method, then it's really the method that takes the type parameter (as parameter or with <T> doesn't matter).
 
4:13 PM
the parameters are defined on the method
 
@kelunik generics are not specific to an instance
generic classes are parameterised types
 
@nikita2206 java has a really stupid method generics syntax
 
Yes, and which type is defined in the constructor and then specific to that instance.
 
Because they have prefix return types
 
@NikiC yeah, calling syntax is pretty fucking stupid
 
4:14 PM
@kelunik no, I don't think you understand what a parameterised type is
a parameterised type is incomplete without its parameters
 
phew... test done.
 
Util.<int, string>compare(...)
 
it is not a type, it is a function that results in a type
If I have class Sequence<T>, then Sequence is an incomplete type
calling a static method on a generic class without providing the necessary type arguments is like calling an instance method statically
 
@Andrea it's incomplete in the sense that you can't create instance of it. Static methods don't belong to an instance
 
@nikita2206 it's incomplete in the sense that the class doesn't exist concretely
 
4:17 PM
@Andrea its static methods do exist. It's just like you can call static methods of abstract class
 
There is no Sequence class. It's abstract. There's Sequence<int> and Sequence<bool> and Sequence<whatever>. Sequence by itself is not a class, it is a template for building one
 
And at least in Java you can't use class-wide generic parameters in static methods
They should define their own parameters instead
 
Yes, because Java's generics are a hack
 
@Andrea Compared to PHP generics, Java generics will be the epitome of good design
 
Java doesn't have generic classes, it has classes with generic-like syntax that's erased at runtime
@NikiC heh
 
Abe
4:19 PM
@NikiC :(
 
(Of course, feel free to prove me wrong on that point)
 
Abe
@Andrea but a prototype has bounds, Sequence could be intended as Sequence<mixed> (in php terms)
 
@Abe ideally most, if not all, generic classes should allow fallback to mixed in PHP, yes
 
Abe
though i kept them separated. ReflectionClass will be just a parameterized class, while ReflectionPrototypeClass is the generic type (and it's not instantiable)
 
@Andrea Yes, but the static functions will still belong to Sequence, just like it's in abstract classes. 3v4l.org/PiNLS
 
4:24 PM
@kelunik abstract classes are different
you can't make an object of an abstract class, but the abstract class itself exists
 
@Andrea just like its static methods
they are defined
 
Abe
@kelunik it's not that she's wrong though. it's just that other languages don't have that
 
anyway, uh
 
@NikiC I'm probably being pretty dense here, but why do you need to hash integers if you switched string hashing to siphash? why can't you treat the integer as if it was the output of the hash algorithm?
 
the point is generics exist at a level above classes, like classes exist at a level above objects
 
4:26 PM
What if I want to have a static method that has some generic parameters logically completely unrelated to the instance itself
 
you can't use a generic function without providing its type arguments
you can't use a generic class without providing its type arguments
the class is incomplete without its arguments
this is in a different sense to how abstract classes are
 
Methods would also be able to have type params, correct?
 
yeah sure
 
Abe
would be good to have them as well
 
a generic class could also have generic methods, conceivably
which means two sets of type arguments to give :D
 
4:29 PM
btw this would induce some noticeable penalty on performance
 
mhm
 
Promise<T>::then<K>(callable(T): K, callable(\Throwable): K): Promise<K>
 
ooh, nice example
 
Fixed, forgot the callable param types :)
 
Abe
but why not using non-static methods instead?
(new Promise<x>)->then()
 
4:35 PM
That was meant to be an instance method.
 
I thought so
you know, I was googling and trying to figure out what static methods exist for
 
Abe
oh, thought you were providing an example for @Andrea
 
"static methods are java's way of doing functions"
wlep
 
Abe
lol
 
4:36 PM
static methods as I see it have maybe two reasons to exist:
 
@Andrea java doesn't have free functions... :)
 
@FlorianMargaine exactly
1) null objects, 2) additional constructors
 
Abe
no named constructors pls :P
 
that's about it
 
Abe
you can just extend the class and override with a different constructor @Andrea
 
4:38 PM
Oh, yeah, I guess so
 
@Andrea and poor man's namespaced functions before namespaces were a thing :P
 
That's kinda silly though
 
Abe
class A{ function __construct(int $a){} }
class B extends A{ function __construct(DateTime $a){} }
 
@QuimCalpe hah, yes :'(
 
Abe
@QuimCalpe lol
 
4:39 PM
user image
2
 
Abe
@Andrea it's not silly, i love it. my issue with named constructors is that once you defined them, they will stay there forever.
class Point2D{
   function __construct($x, $y){}
   static function fromPoint2D(Point2D $xy){}
}
class Point3D extends Point2D{
   function __construct($x, $y, $z){}
   static function fromPoint2D(Point2D $xy){} // can't get rid of this...
}
stupid example, but works...
 
you can't get rid of __construct parameters either
 
@Andrea If you're thinking about the Sequence example, I agree that the types should be required for using static methods, since Sequence doesn't really exist as you said, only Sequence<T>.
 
Abe
@Andrea you can.
 
also Point3D shouldn't extend Point2D, wtf
 
Abe
4:42 PM
__construct is free
> stupid example
 
well it's an example that doesn't demonstrate your point convincingly
@Abe oh. that makes sense, I guess
 
@Abe what do you mean? static methods don't have to be polymorphic
 
begs the question: why do classes inherit static methods anyway?
 
Though I'm not sure if they are in php
 
Abe
^ reasons to avoid statics at all
only static fields possibly private and protected are useful, sometimes
 
4:45 PM
@Andrea This is a big problem with named constructors IMO. You can't get rid of them if you want to extend the class. So now you have ChildClass::fromWhatever(): ParentClass :(
 
Abe
what about null objects @Andrea ?
 
Solution: make the class final.
 
@Trowski that shouldn't be a problem if you're extending classes appropriately?
@Abe is this re: my 1st reason for static methods?
 
Abe
yes
 
@Andrea Usually not, you probably just have to override fromWhatever() to return an instance of ChildClass.
 
4:46 PM
you can't call methods on nulls
 
Abe
and why you need static for that?
 
you can have a static method which deals with an instance of that class, or a null object
this is a rather silly and exotic use case though
@Trowski ahh
oh great, that makes it a complete mess
objects were a mistake
 
Abe
@Andrea :P
 
@Andrea You don't have to... but otherwise you have this static method out there that doesn't make a lot of sense.
 
php -r 'class A{static function foo(A $f){}} class B extends A {static function foo(B $f){}}'

Strict standards: Declaration of B::foo() should be compatible with A::foo(A $f) in Command line code on line 1
// yeah, go php
 
Abe
4:48 PM
@nikita2206 yeah static methods shouldn't be forced to be polymorphic
 
@Trowski maybe I'm being naive here, but return static(...) doesn't solve that?
 
@QuimCalpe As long as ChildClass doesn't have different parameters for it's constructor.
 
@Trowski yeah sure...
 
Which is the problem with new static()... you just locked child classes into the parent's constructor prototype.
 
know what? static anything in classes was a mistake and is a complete mess
static properties are nonsense
they also have terrible syntax
 
4:50 PM
@Andrea Generally yes :)
 
we should deprecate static methods and properties entirely
 
What was the consensus on the RFC regarding trailing commas in argument lists, etc.? Can't seem to find it
 
this would get rid of that syntax I hate oh-so-much and fix all the problems with static stuff
@Sean "No."
 
@Andrea :V Alrighty, thanks!
 
4:52 PM
now, if only we had namespaced variables
alas
 
but BC break is too big
 
@Trowski That's a problem with the return type system, not a problem with named constructors:
class foo {
    public static fromBar($x, $y, $z) : static {
        $instance = new static();
        $instance->whatever($x + $y, $z);
        return $instance;
    }
}
 
Abe
@Andrea private|protected $fields are useful sometimes, for data shared between all existing instances. and with that i mean it properly
function __construct(){ self::$instances++; }
function __destruct(){ self::$instances--; if(self::$instances === 0) unset(self::$shared); }
 
@RonniSkansing we can gradually discourage people from using them
@Abe can be done better with a manager object that provides itself as a dependency
dependency injection, people!
Factory, even
what we need, people, what we need... is object constants
 
Abe
yeah but it's very internal stuff, like a huge array
 
4:54 PM
@Abe er, so?
 
@Andrea cut the head of the snake (Laravel)
 
@Danack Yeah, you can solve it with new static, but again you've locked child classes into having the same constructor.
 
Abe
an huge array <ins>that you intend to modify</ins> @Andrea
 
@Abe okay. why can't that be in a factory?
 
Usually if a class has named constructors, it's actual constructor should probably be private.
 
Abe
4:55 PM
very internal stuff
 
we should have such a thing as constructor methods
 
I want to ignore /dir except for /dir/subdir... Y U SO HARD?
 
static function ...(...) { return new self(...); } is a hack
 
Apparently I suck at glob/fnmatch
 
Abe
@Andrea though i could easily live without static eh
 
4:57 PM
@DanLugg /dir\n!/dir/subdir/
or the other way around, don't remember
 
Abe
@Andrea also, you meant a DTO, right? :D
 
@Abe I so rarely use static anymore because it's such a mess. Namespaced functions FTW!
 
@andrea re your recent static bug, unsure if relevant, I had some issues with static recently - might be related cause/fix wise - bugs.php.net/bug.php?id=70918
 
Abe
@Trowski true
 
@tereško are you there?
 
5:01 PM
yes
 
@Leigh seems to have been fixed
lemme check for sure
 
look, I have a consultation, can I tell it to you now? (it is more related to JS)
 
Abe
good chat @all
 
oh
your first issue was already fixed. ahhh.
 
Abe
i forgot what i was doing though :P
 
5:02 PM
oh, it was all fixed...
@Leigh my issue was me
 
@Andrea ah, ok :)
 
I wrote Closure::call. I did a bad job. That was the problem.
 
@Shafizadeh sure, go ahead
 
It's technically PEBKAC but not in the user error sense :)
 
though, isn't it already in JS room?
 
5:03 PM
I didn't read in detail, I just saw it was in a bunch of SPEC_HANDLER stuff, same as mine, took laruence a couple of goes to fix it, so was just checking
 
@tereško yes it is. you read it?
actually I need to a vain-button on browser
 
@FlorianMargaine Hmm, nope.
I thought that'd work, but it just ignores all the things.
/src
!/src/foo # still ignores everything in /src/foo
 
You know what? Generics are complicated. Let's not do them.
Add templates instead :p
(no, that's probably not a good idea either, is it?)
(it's not very PHP, either...)
ah, no, I have teh solution
full generics: eval('class Foo { ... public function addItem($type \$bar) { ... } }');
it's the PHP way
 
Generics would be really wonderful. With them I'd really like to introduce a Vector<T> class and a Map<K, T> class and tell people to stop using arrays.
 
@Leigh We could certainly do that. It simply wouldn't prevent hashdos
It would prevent it for string keys, but not for integer keys
 
Abe
5:13 PM
@Trowski they are both useful. arrays are useful as they are pass by value. but i would like an oop interface on them
 
can we have a custom siphash exception handler so you can make your server retaliate and launch a DDOS against your attackers
thanks
 
@Abe Perhaps instead of classes they could be a pair of new scalar types.
Not sure if ^ is possible. Parameterized scalar type?
 
@Trowski arrays can never die
interoperability is an issue
 
@Andrea They wouldn't really die... just providing a way to make something more type safe.
 
hmm, a pseudo-type then
Like, we could define set to be an array with null keys, vector to be an array with only contiguous ascending integer keys matching insertion order, etc.
 
5:16 PM
Exactly.
 
that sounds like a good approach
we don't even need generics for that, actually
I want to revive arrayof somehow, without the performance issue
 
vector could allow any type for it's members. Generics could add a vector<T> that could only hold T.
 
sure
but we don't need generics to add that
 
Right.
 
So, arrayof, I want to revive it
 
5:19 PM
@Trowski First, I have no problem with that, as when I'm using named constructors, I always make sure the constructors are empty, without any parameters. Also "software entities should be open for extension, but closed for modification"....
 
The solution: array<int>(1, 2, 3);
 
Is checking the type when assigning to an array a big performance hit?
 
@Trowski that's not the problem
the problem is if you have an untyped array being checked against a typed array hint
if it has 512 elements, that's 512 checks. O(n). bad.
 
@Andrea Ah, that would be awful.
 
I think checking it once is fine, but multiple times would be an issue. So, idea:
 
5:20 PM
That's where having something like vector<T> would be useful, because then you know it can only hold T.
 
1) you can construct typed arrays with array<foo> ( ... )
2) you can use the array<foo> syntax as a type declaration
3) if you give an array<foo> an untyped array, it will validate and convert
 
and reject references from it?
 
@nikita2206 something like that
 
That seems reasonable.
 
problems: oh god strict and weak types
(also an issue for properties)
in order to be practical I think property types should probably be exclusively strict
 
5:26 PM
@Danack This makes sense, especially if the constructor is private (unless an empty constructor can create a valid object as well).
 
return types should have been too, I suck
 
@Andrea Property types can be weak, they just do the casting before assigning.
 
@Trowski I usually make it private for the reason that i'm stupid.....and forget to tell Auryn how to create a particular object....
 
@Trowski the problem is deciding which mode to use
 
@Andrea Always strict of course :)
 
5:28 PM
So, 7.0.1 will deprecate weak mode, right?
 
But in what context to you mean? Like when assigning to array<int>?
 
@DanLugg no :p
it'll stick around until at least 8
 
7.0: See? Why the fuck would you use weak mode?
7.0.1: What's weak mode?
 
the thing about weak mode is you don't choose to use it
it's the default
 
Dammit markdown.
 
5:30 PM
which means you can like, use PHP, without knowing about type hints
 
Yea, which is silly.
PHP: WE HAVE SCALAR TYPEHINTS NAOW!
Everyone: Oh cool, I better update my code to supp...
PHP: YOU DON'T HAVE TO USE THEM!
 
I wonder if parameter and return types are the furthest we'll go
 
@DanLugg weak mode is for people who want PHP to be more like Ruby
 
I think weak and strict types makes a lot of sense though. You can finally know your function will get the type you declared without having to do more work. The caller can code as crappy or as well as they'd like.
 
@Trowski yeah
and it means we can add strict types to stuff without upsetting people who like weak types
that was the other reason
 
5:32 PM
@tereško If sausage mode is for people who want hamburgers shaped like sausages, then those people should just go get a damn sausage.
 
also if you're very lazy it makes frontend code easy
 
People were just too afraid strict types would make PHP a typed language. I wouldn't be surprised if strict becomes the default in 8 (would so vote for that).
Then you'll have to use declare(strict_types=0) to turn it off :)
 
@Trowski it wouldn't
 
@DanLugg judging by the twitter outrage fest that was the "eggplant emoji", PHP having a "sausage mode" would be found offensive by someone
 
again, it would break everything
 
5:34 PM
@Andrea BC and all I suppose
Bah
 
@Trowski make it an ini setting first.....
 
a big advantage of making strict opt-in is it lets us strictly type the stdlib
@tereško what
 
@tereško Funny, I never thought eggplant would compliment peach, but in emoji-land...
 
Abe
@Andrea only very old code. it's like thinking of php4 now. would you support php4 stuff today?
 
eggplant's been in emoji since forever
there was never a time there could be an outrage
 
are you imagining things?
 
@Andrea eggplant's been in emoji a penis since forever.
 
@tereško oh, but that's different
 
being offended by random shit is a trend
 
that's instagram censoring a hashtag because sex
@tereško they're banning it for innuendo
censoring sexual things is as old as time itself
 
5:36 PM
> PHP having a "sausage mode" would be found offensive by someone
 
Next they'll ban cucumber emojis.
 
@Trowski perhaps!
@tereško if the entire thing was a dick joke, possibly
oh right I gotta go eat
cyaz
 
lol
the entire thing makes me think of people being bad at "rorschach test"
 
Somehow people seem to have the impression that they have the right to never be offended. I'm not sure how this happened...
 
btw, watched the review of TB's for Star Wars: Battlefront .. it seems to be as bad as I expected
 
5:56 PM
@tereško Disappointing. Was so excited when I saw the game.
 
Ever try something so new you don't even know what words to search for?
 
Abe
6:30 PM
@SuperNoob all the time
 
I have 50k job listings that I'm trying to find a way to sort into categories based on titles...so apparently I'm learning NLP libraries today
 
Abe
tried boolean fulltext? @SuperNoob
 
Never heard of that.
 
Abe
you should be able to get a decent sorting with that
search about "fulltext" it's usually supported natively by good dbms
it's not very customizable, but often good enough
otherwise try stuff like sphynx search
 
What is "home" button on the keyboard?
 
6:39 PM
Hmm. So would this be a decent approach: create a table of words, go through all titles and give each word a count, then go back through the titles using the top X number of words by count to group the titles?
 
Abe
check how fulltext works first, because it sorts sensibly already
 
@SuperNoob This is something I haven't used, but it sounds like a set of problems that are going to be easiest to solve with a graph datastore like neo4j.com
e.g. you want to be abel to measure how one label 'overlaps' with another label....
 
Abe
also that could be a 'WITH QUERY EXPANSION' case
or, you could keep a db of words updated on write, rather than calculating it every time
 
mormrornogni all
 
mo'nin'
 
Abe
6:46 PM
mormoronig
 
@Shafizadeh it usually goes the the "beginning" (of a page, of a line)
 
I got it ... (if your focus isn't in a textarea/input)
 
Hole fucking shit @Gordon. That is awesome. Both because of the technique and because of rebecca
That's a win in my book
 
Abe
respect
the php?> makes me think he wasn't trolling them though :P
 
yea
 
6:55 PM
@PeeHaa he needs a better intern
 
Abe
@nikita2206 around?
 
@Andrea congratz! I'm afraid I won't be able to fix any..
 

« first day (1868 days earlier)      last day (3080 days later) »