last day (295 days later) » 

7:57 PM
I need a 15 minutes to finish something, then I have time...
 
Is there a way to invite more people to the room?
Or do we just have to link him?
@bwoebi That's fine.
 
try it and ask if they got the ping?
 
@JoeWatkins Ping.
 
Ah, there is an option to "invite this user..."
 
8:00 PM
so, what we discussing then ?
 
Bob needs 15 minutes-ish to finish up.
 
kk ping me again ...
 
I plan to talk about why we want type hints in the first place, talk about return type position, and about options for supporting null.
 
8:11 PM
@JoeWatkins @LeviMorrison back
 
cool
 
Jolly good.
 
Just we or does anyone else participate too here?
 
I pinged others but nobody responded.
Anyone in particular you have in mind?
 
No, maybe Nikita or Peter?
 
8:15 PM
I sent an invite to Nikita.
Well, he doesn't seem to be responding at the moment.
So first I wanted to talk about types and null.
 
We can already talk here, maybe put a link into room 11 so that they can join in if they find it?
 
yo
 
Welcome ^^
 
@LeviMorrison Actually when you prefer the ? syntax I find it more logical to put it behind, just like PHP users are used to regex where it's behind too.
@ircmaxell morning :-)
(I know the Hack syntax, just saying my personal opinion on that)
 
In my opinion the point of types are to add constraints to the system in a particular point, intended to ease development.
 
8:21 PM
Foo? to me indicates 0 or 1 foo... Just like Foo+ would be 1 or more, and Foo* would be 0 or more
 
By knowing the type in this place I know what I can and cannot do with something.
 
@ircmaxell just take 0 as NULL and the logic fits?
 
A major complaint that I found on the ML archive was that it doesn't allow null by default.
 
@LeviMorrison which is lunacy at the root
 
I agree.
 
8:23 PM
null by default sounds like a bad idea...
 
anyone who's used Java will curse you for mentioning NullPointers, and they want it as the critical feature
 
Based on what I've read it seems that I should change my stance on not proposing a null modifier.
 
it simplifies 5% of cases, at the expense of the 95%
 
I agree.
evening @NikiC
 
especially around returns
 
8:24 PM
As the RFC currently stands I have it only supported on object types (not for array or callable)
What are your thoughts on that?
(Direct syntax aside)
 
I think if you support nullable, any value should be nullable (via the indication), just for consistency
it's weird having objects be nullable without callables being nullable
 
I'm just wondering why we need nullables. Actually you just return null in an error condition and then we also just can throw an exception which is usually easier to handle?
 
politics.
 
The major reason in my mind is acceptance. It is a widely used pattern to return null for a 'missing' object.
 
8:28 PM
the patch allows for nullable and array and callable, array and callable are consistent with the current hinting the engine allows, I think it should be consistent with that ...
 
exactly my thoughts ^^
Since parametters are already nullable, the returns of the same type should be
 
I am positive we'd get too much backlash by omitting a nullable option, even though it is future compatible.
 
the nullable I'm not so bothered about the only thing is that hhvm are doing it and why implement half of something they already have, it's only making life difficult ...
 
IF you support nullables at all
@JoeWatkins can you elaborate?
 
hhvm have the ?Type syntax for return hints right ?
 
8:29 PM
@LeviMorrison So, what is the advantage over just throwing an exception? // And please, first talk about what's best, then we still can debate about politics?
@JoeWatkins jup
 
@JoeWatkins yup
 
@bwoebi I agree that exceptions are often a good choice.
 
so I think it's verging on destructive to implement hints differently to them whatever, I don't necessarily like it but that's how it's got to be I think ...
 
for the record, I'm also having certain doubts regarding the usefulness of nullable return types
 
@LeviMorrison Well, that and the NullObject pattern usually represent the majority of those cases
 
8:30 PM
@NikiC I think everyone in this room agrees with you ^^
 
@NikiC nobody here's going to argue that, it's the majority of the people on internals that will
 
@LeviMorrison I actually can't imagine a real use case of nullable where it's the optimal solution. Except maybe in internal code (≠ API) where you care about performance, but there you then also don't provide a type hint.
 
@ircmaxell I don't see that as a problem, given that it can easily be added lateron
Adding nullability via ?Type would for me also imply adding the same support for parameter typehints. At which point I think the whole thing is outside the scope of one RFC
 
@NikiC good luck with that one. Look at Joe's collection discussion and how many people were bitching about not supporting nullable values
that wasn't why it failed, but was a big point of contention (and for the record, I think the correct stance was taken)
 
@ircmaxell I must have missed this; link?
 
8:33 PM
@NikiC that's logical ... but I don't think that matters, the path of least resistance is going to be do whatever hhvm are doing ...
 
@NikiC Actually it's already possible via a default null parameter and this is fine…
 
@JoeWatkins Yes, so we also implement generics and everything else, right?
 
well if we are to have generics I don't see that it can differ much from theirs is what I am saying ...
 
We're only implementing a subset here anyway. And that subset is compatible
 
that seems to be the way it is doesn't it ?
 
In my mind, generics aren't useful until we have return type hinting and other type features.
One step at a time.
Plus, I'm not so sure we need generics (would be nice sometimes though)
 
@bwoebi It's not fully possible and not using that syntax. If we add that syntax for return types it must also be supported for parameter types, otherwise it is inconsistent
 
Anyway, that's a bit off topic, sorry.
 
@NikiC also true ...
 
@ircmaxell Oh, as part of the ArrayOf proposal. I guess I didn't read enough mails on it.
 
8:35 PM
(The mention of generics was just me making the point that we're not implementing everything HHVM supports, so HHVM is no argument to support the ?Type syntax right away)
 
@LeviMorrison using them for a bit, yes, I think PHP could do great with them. They open a huge door. But not going down that road now
 
I know we aren't but I just don't see that we are going to be able to implement anything they implement first and differ on the implementation at all really ...
 
@NikiC for the functionality point, I agree. For the syntax point, I disagree. If we implement overlapping functionality, I think sticking with compatible syntax is important
 
And regarding the = null syntax for parameters, it differs from ?Type by not only setting allow_null, but also making it optional.
 
and doesn't it just make it harder for the programmer to know what and how they can hint, doesn't it just make it easier for everyone if we have compatible implementation of the same idea in every detail ?
 
8:36 PM
@NikiC yep, I agree. We still can first propose it without nullables, explain why we prefer to not have them (hard part) and then we can analyze why it fails; we have plenty of time now to do it in small steps.
 
tl;dr: As introducing nullable return typehints also requires changes to other parts of the language (namely parameter typehints), it is outside the scope of this RFC and should be handled separately :)
 
I think if we propose it separately it needs to happen at the same time. This way people with null concerns can see we are actively proposing a solution for them.
 
it's less likely to get anywhere if we go fucking with param type hints too I think ...
 
Great. And we can easily vote no on that one if needed. A few no votes from us should suffice to turn the vote.
We just need to make the one vote happen after the other.
 
So propose RFC on return type and one on nullable.
Then after vote on return types is finished, open the one on nullable.
 
8:41 PM
@bwoebi While I also think that Type? reads nicer and is more intuitive, it might cause issues with a future implementation of generics, because Vector<Type?> would contain a ?>. Basically the same issue you had in C++ with the >> shift / template ambiguity. As such ?Type is safer syntax wise.
 
If latter doesn't make it, we don't care.
 
@LeviMorrison I like it
 
@NikiC ?> we can fix via entering in a different lexer mode at that moment. That's a non-issue I think.
 
@NikiC then we'd have to completely remove short-open-tags, as <?Type would be there as well...
 
@ircmaxell I assumed that short open tags will not be present by any time we'd consider adding generics
 
8:42 PM
To be honest, most collections don't allow null entries anyway ^^
 
@bwoebi that kind of added complexity is a problem, and will face opposition
 
@ircmaxell Opening a context in an open context doesn't work…
 
@bwoebi we're not talking compilable, but at the lexer level.
@LeviMorrison yay!
 
@ircmaxell It'd be a Syntax error in every other case…
 
oh yeah that'll work, but I'm not sure what the rfc for nullable param hints would look like
what does ?myClass $object = null even mean ...
 
8:44 PM
We can work on that in a moment.
 
@JoeWatkins that looks totally weird.
 
@bwoebi yes, but because it's an unexpected token, not because it failed to parse...
 
of course it does
 
@bwoebi Yes, and that's ugly... however, thinking about it we'd probably have to do it anyways to handle the >> issue.
 
but that seems to be what we are proposing ?
 
8:44 PM
@NikiC for nested generics?
 
@ircmaxell at the lexer level we're already in an other mode at that moment. (in html mode vs. in PHP mode, just create two rules)
 
@ircmaxell yes
 
@NikiC yup
 
@NikiC so a parser rewrite. Yay!
 
plus does hack support that kind of hinting for function params ?
 
8:45 PM
Great discussion. So can we get back to return types right now?
2
^^
 
lol
 
@ircmaxell That must be handled purely by the lexer. Lexer/parser dependency sucks balls
 
But still not sure if we'd really need generics anyway… :-D
 
or would we be creating incompatibilities there ?
 
@NikiC when I say parser, I mean lexer. When I say compiler, I mean parser. I suck at names...
@JoeWatkins I don;'t believe so
 
8:46 PM
@LeviMorrison good idea...
 
@ircmaxell huh
 
right so that's a nogo then isn't it, we can't actually make param hints incompatible with hhvm can we ...
 
omg it does
that's horrible
 
I stand corrected
 
8:47 PM
why?
It's not any more horrible than nullable return types
 
Nullable is very useful for primitive types that don't generally allow null as one of their values, such as bool and int
this has no meaning here
 
I actually knew that but was trying to keep conversation focused ^^
 
actually, nullable parameter types make some sense, much unlike nullable return types, which are just useless...
 
actually, think about that when we have once scalar types… which I actually oppose.
 
8:49 PM
@ircmaxell lol
 
@LeviMorrison So, what is it you want to get back to?
 
Position.
 
after is okay with me
 
I know Bob is unhappy with it after the parameter list; he is not the only one.
 
so wait a minute, what if we propose them both and they are both voted in ... and then we have that horrible syntax on method hints ?
 
8:50 PM
mainly because that makes the function names align, really :D
 
I;mnm out, later
 
I'm not the only? that's new to me…
 
Will and Felipe both don't like it after the parameter list.
Can you think of any technical reasons to do it before the function name?
 
can we really do that ?? you are talking as if it's an option and I don't see it as one ?? could we really say fuck you to hhvm like that ??
 
@JoeWatkins sure ^^
 
8:52 PM
@LeviMorrison there are just as much technical reasons to do it before as after...
 
@bwoebi I disagree.
 
if we can I'm totally up for whatever, but I can't help thinking we don't really have the power to decide anymore ...
 
By putting it before the function name you break searchability and I know some who would vote no based on this alone.
Ilia and Rasmus, namely, and probably more.
 
that's an usability reason. Then I can also state that the type gets more visibility if it's at the very beginning of a line.
 
it somehow makes more sense before the function I think, are they to have default values ?
 
8:55 PM
@bwoebi To which one might respond that the return type is less important than the name of the function ^^
 
I am going to post some code snippets and I want you to read them out loud to yourself from left to right.
function map(callable $f): Collection;
 
it doesn't help
 
Collection map(callable $f);
 
you write it one way I see java / c#, the other I see C
 
@NikiC I'm beginning to wonder why the C authors did it that way
 
8:56 PM
I'd read the first like so: function map takes callable $f and returns Collection.
 
@bwoebi dice?
 
@NikiC Actually a return type is tightly bound to a function...
@NikiC I bet no :-D
 
I can't even think of a good way to pronounce the second way.
 
@bwoebi I'm pretty sure.
 
@NikiC ask them?
 
8:57 PM
You know, that was back in the day
 
A function returns Collection, its name is map, and takes callable $f
 
They just happened to base C on that language, rather than that one.
 
@LeviMorrison so, you prefer function Collection map (callable $f) {} ?
 
@bwoebi Just so you don't base any arguments too much on "this is how C does it". Here's the parameter type syntax that the original K&R C used:
int main (argc, argv)
int argc;
char *argv[];
{
    return(0);
}
 
@bwoebi No. I can tolerate it because it is what C does ^^
 
8:59 PM
yeah terrible
 
@LeviMorrison I mean, that's terrible too… then we need to drop the function keyword^^
 
By the way, there is a language out there that the following is how you would define it:
 
Collection static public abstract function map(callable $f); MUAHAHAHA
 
function map takes function a returns Collection
 
static public abstract Collection map(callable $f); please :o
 
9:00 PM
I think identifying a function in this order makes a lot of sense
 
public function method(Callable $callable) : Type {}
public function method accepts callable returns type
Type public function method(Callable $callable) {}
returning Type, public function method accepts callable

the first one makes more sense to type and read, but they both seem familiar ...
 
"I am defining a function, its name is map, its parameters are callable $f and returns Collection."
 
How is that called? Osascript? That natural language thing from Apple?
 
omg
 
It's weird.
 
9:01 PM
@bwoebi It's a video game language called JASS actually.
 
this is all very weird ...
 
lol
 
I hope they don't call it a programming language. That would be insulting.
 
So in any case, I can think of reasons for not putting it between function and the function name (and also not replacing the function keyword)
And I think they are good reasons.
Are we in agreement that putting it before the function keyword is just odd?
 
@LeviMorrison Yes
 
9:03 PM
Yes
 
also in the prefix version the return type feels somewhat lost in all those other flags
 
So that leaves after the function name but before the parameter list, and after the parameter list before the curly brace.
 
write C… static inline __attribute__((packed)) int map();
Does it look weird there? Not weirder as in PHP, I'm sure...
 
@bwoebi add dll export and fastcall convention to that :D
 
I suppose technically we could so something like: function map(callable $f; Collection); but I think that's a no-go too ^^
 
9:07 PM
@LeviMorrison yeah ... no
 
@LeviMorrison yes, nope.
@NikiC and an unused attribute too, no?
 
So really the only option I see is function map(callable $f) Collection; or some similar variant.
 
I think the choice is really between function map(callable $f) : Collection; and function map(callable $f) -> Collection;. Those are the only two possibilities that I find nicely reading in PHP
 
The former is what Hack has done (and I think some others); the latter is from lambda C++
 
I seem to be the only one to not find weird the syntax where it's before the parameter list? :-/
 
9:09 PM
and given that hhvm already uses the former and I don't have any technical issue with it, I think that's the way to go
 
@bwoebi Can you give the example I've been using in the notation you suggest?
@NikiC It's also one character shorter.
 
another argument why trailing return might be better:
 
@LeviMorrison <modifiers> <return type> <name> (<parameters>);
 
@bwoebi And no function keyword?
 
yes
 
9:12 PM
Java uses the imho incredibly super ugly syntax for method generics: static <T> Collection<T> arrayToCollection(T[] a) {} The <T> has to occur so early in order to make it usable in the return type
with a trailing return type one can use the much more natural static arrayToCollection<T>(T[] a) : Collection<T> {}
 
@bwoebi I am okay with that because it is C-like. But it breaks searching and removing the function keyword has been proposed in the past and shot down.
Given that I'm only okay with that syntax and there are problems... I'd have to lean to after.
@NikiC Interesting.
 
@LeviMorrison how do you do it in C to search for a function definition?
 
You don't. That's exactly the point.
You have a tool because it's non-trivial to write an expression yourself.
 
@bwoebi I use :!git grep function_name and look through the list :D
In absence of lxr that is
 
Actually I just grep for NAME ?([^)]*) ?{
 
9:16 PM
Compare that to n function_name which is what I do.
(very few false positives, btw)
 
I gotta bail, update the rfc and I'll bring the patch inline with that ...
 
Hehe, I grep always for the full function function_name, which is just about as much chars as the grepping in C…
 
So, I know you prefer the C style syntax, but are you okay with after @bwoebi?
After this discussion?
 
I can live with. I won't vote no because of this, it's just not my preference.
 
Okay. Any other concerns with the return type RFC?
 
9:23 PM
No, rewrite now the RFC according to what we discussed, then let's look again over it and propose it on the ml.
 
Sounds good.
@NikiC Anything else on this RFC? Or the new nullable one?
 
@LeviMorrison nop
 
Then I'll make a new RFC and update the return type RFC.
Thanks for the discussion, guys.
 
Uh, I wanted to do fix some php-src bug today, but now it's gotten a bit late, hehe
 
@bwoebi which one?
 
ah, that one
 
10:28 PM
Super preliminary RFC on Nullable Type-hints: wiki.php.net/rfc/nullable_typehints
 
10:39 PM
And if possible present the problems in a better, more persuading way without showing which opinion you have on the topic :-)
 
^^
room topic changed to PHP RFC: Return Type: A place to discuss the Return Type-Hint RFC. [php]
 

  last day (295 days later) »