« first day (2823 days earlier)      last day (2107 days later) » 

6:04 PM
@Wes No, it's for functions like reversed which can only reverse certain types of things.
 
Wes
i don't understand
 
@ircmaxell I want to create a type variable which is not a parameter whose value is obtained from a type argument of the type parameter. If you read that slowly and carefully I think you'll get it. I'll try to think of another example.
@Wes I cannot efficiently reverse arbitrary iterators and data structures. An Iterable which returns certain kinds of iterators is reversable, but not Iterables.
 
Wes
you don't need a type variable for that
interface x<T>{ function getIterator(): Iterator<T>; }
 
No, Wes, that doesn't work.
 
Wes
how doesn't it work?
 
6:07 PM
That is an arbitrary iterator. I cannot efficiently reverse arbitrary iterators so I don't accept them.
 
have you tried asking it on software engineering?
 
I need to be able to say something like:
function reversed<Element>(Iterable<BidirectionalIterator<Element>> $i) {
    /* ... */
}
 
Wes
yes but why not just
function reversed<Element>(BidirectionalIterator<Element> $i) {
what's wrong with that?
 
In reality it's a more complicated type than that but this is one piece.
 
@Wes wouldn't that make BidirectionalIterator a class and not a type?
 
Wes
6:10 PM
wat
 
Something more like Iterable<BidirectionalIterator<Element>> | BidirectionalIterator<Element> | ReversableAggregate<Iterator<Element>> | Array<Element>.
Reformatted:
    Iterable<BidirectionalIterator<Element>>
|   BidirectionalIterator<Element>
|   ReversableAggregate<Iterator<Element>>
|   Array<Element>
 
reversible
sorry
 
Wes
reversable
 
reversable is not a word
 
Unsurprisingly like so many words in English there isn't agreement.
 
6:13 PM
seems like an old spelling for it
 
Perhaps, but it's one that makes sense, reverse + able...
 
true
but when did English ever make sense...?
ghoti for example
 
user9059272
Hi all
 
user9059272
The string in PHP is implemented as an array of bytes and an integer indicating the length of the buffer.
 
user9059272
What's the exact meaning of buffer in this statement?
 
Wes
6:16 PM
@LeviMorrison so you want to say like IteratorAggregate but only if getIterator() returns BidiIterator ? the type declaration would be:
class<T> implements IteratorAggregate<T>{ function getIterator(): BidirectionalIterator<T>; } | BidirectionalIterator<Element> | etc
in practice you override it inline and you have a more specific return type
 
Does any language even support that sort of thing?
 
Wes
some language does but i don't remember which
 
I've never seen it and have been looking, but without knowing terminology it makes it very hard to search.
 
user9059272
By buffer does it mean the location in memory where the string is stored temporarily?
 
Wes
might ask @rightfold
 
6:18 PM
In any case I don't see how that is superior to the proposed design.
 
user1804599
Yay please I want to be helpful.
 
Wes
@rightfold what's that language that can create anonymous types on the fly, like var MyType = class { function bar(): Baz; };
 
user1804599
F#, Go, Java, Scala, TypeScript.
 
Wes
@rightfold and also in a type declaration?
public void baz(class extends Bar{ void qux(); } varName);
 
user1804599
6:21 PM
Seems you're looking for associated types.
 
user1804599
Rust and Scala support this.
 
@ircmaxell Here's another example. We don't want to lose the detailed info as to which inner iterator we have:
interface <K,V> OuterIterator<out T: Iterator<K, V>>
        extends Iterator<K, V>
{
        function getInnerIterator(): T;

        function rewind(): void { $this->getInnerIterator()->rewind(); }
        function valid(): bool { return $this->getInnerIterator->valid(); }
        function key(): K { return $this->getInnerIterator()->key(); }
        function current(): V { return $this->getInnerIterator()->current(); }
        function next(): void { $this->getInnerIterator()->next(); }
}
 
user1804599
interface Iterable {
    type Iterator;
}

interface Iterator {
    type Element;
}

class MyIterable implements Iterable {
    type Iterator = MyIterator;
}

class MyIterator implements Iterator {
    type Element = Integer;
}
 
user1804599
Then you can write constraints like this:
 
user1804599
void printAll<T, I>(it: T) where T: Iterable<Iterator=I>, I: Iterator<Element=String> {
    ...
}
 
user1804599
6:24 PM
You can also have a constraint that just says T: Iterable. Then, T::Iterator is an opaque type.
 
user9059272
Is someone going to help me?
 
user1804599
For your use case:
 
user1804599
Option<E> findMiddle<T, I, E>(it: T) where T: Iterable<Iterator=B>, I: Bidirectional<Element=E> {
    ...
}
 
Wes
why is scala so odd
 
user1804599
This is pseudocode. I can write up a working Scala example if you want.
 
@NikiC as far as I see on the mailing list there's quite a broad consensus to for an additional PHP 7.3 alpha for the RFC … but if we don't move now, we can nevertheless forget it ...
 
I have 3 type variables: K, V, and T but only 1 type parameter. How would you encode that into say, Java, C#, Swift, or Rust?
 
Wes
imho that's the wrong abstraction... if you can't reverse efficiently then do it inefficiently
 
@Wes Then look at the OuterIterator case where it appears again.
As I've said, this is more general.
 
user1804599
6:33 PM
@LeviMorrison I'm not aware of a language that can do this in a type definition.
 
Wes
also there is no such thing as reverse iterator. you reverse the stream/collection, not the iterator
 
@Wes Not true, trees have many traversal techniques without changing the structure at all.
 
user1804599
Well, with associated types you could do this.
 
C++ can do it. I think they are called "template template parameters".
 
user1804599
But it will be slightly different.
 
user1804599
6:35 PM
interface Iterator {
    type K
    type V
}

interface OuterIterator<T: Iterator> extends Iterator<T::K, T::V> {
    function getInnerIterator(): T;
    function key(): T::K { ... }
}
 
user1804599
Alternatively (possible in C++, but C++ templates are really glorified memoized macros):
 
user1804599
interface Iterator<Key, Value> {
    type K = Key
    type V = Value
}

interface OuterIterator<T: Iterator> extends Iterator<T::K, T::V> {
    function getInnerIterator(): T;
    function key(): T::K { ... }
}
 
user1804599
If you allow omitting type arguments in superclass constraints.
 
user1804599
I see no reason why you couldn't have this, though:
 
user1804599
interface <K, V> OuterIterator<T: Iterator<K, V>>
 
user1804599
6:37 PM
Whenever K or V is needed, you look it up in the ancestors of T.
 
I understand these examples, rightfold. Rust, Swift, Scala have differences in how their associated types work but why is that associated types can be referred to via T::K but generics cannot?
That property holds true in all these languages but I don't see why it has to be that way.
 
user1804599
I don't really know.
 
user1804599
The latest Scala compiler actually desugars type arguments to associated types, but with hidden names.
 
Edit: (you posted this already, just didn't notice)
Does Scala let you have default type parameters? [T = int] type of thing?
 
user1804599
I don't think so.
 
Wes
6:41 PM
interface OuterIterator<out T: Iterator<K, V>> extends Iterator<K, V>
 
@Wes How does it know K and V should be type variables instead of types literally named K and V?
 
Wes
no
 
user1804599
I guess automatically exporting type arguments as associated types would be useful and solve this problem nicely.
 
Wes
yeah ignore that
 
user1804599
Perhaps you can make these equivalent:
 
Wes
6:44 PM
interface OuterIterator<K, V> extends Iterator<K, V>{
    getInnerIterator(): Iterator<K, V>;
}
outeriterator is also failed abstraction... why you (spl?) want/need to access the wrapped iterator?
 
user1804599
class C<A, B> { function f(): A; }
class C { type $1; type $2; function f(): $1; }

function f(): C<Int, Double>;
function f(): C<$1=Int, $2=Double>;
 
user1804599
Or retain the names, though that would make them part of the interface, and complicate the desugaring of type application.
 
@SerialKisser the size of the array of bytes stored in memory yes
@SerialKisser if you're curious: nikic.github.io/2015/06/19/…
 
New record of rfcs in vote at the same time? :D
 
6:52 PM
@rightfold I'm not sure how they'd interact with default types, which I think we need in order to preserve BC.
 
Wes
good news is, wordpress has no case insensitive constants :B
 
How does <T: Iterator> know that I want the associated type vs defaulted?
 
Wes
can someone clarify on
In PHP 8.0: true, false and null are converted from special-cased constants into reserved keywords.
 
user1804599
True, false, and null are case-insensitive constants.
 
user1804599
This is why \TRUE works.
 
user1804599
6:54 PM
@LeviMorrison You can make Iterator<> syntax for inhibiting defaults.
 
Wes
so it proposes to make the existing keyword (e.g. true) case insensitive?
 
user1804599
True isn't a keyword.
 
Wes
true is, TRUE isn't, afaik
define("TRUE", true, true);
 
@rtheunissen I still object to the handler doing the conversion to int/bool. I still maintain it should be the construct using it that does the conversion.
 
@LeviMorrison I prefer the single point of entry with consistent returns, even though it's defensive.
 
7:01 PM
We've already discussed this and I'll be sad if it stays that way. It prevents general operator overloading in the future for very little benefit.
Most of the constructs will have to do conversion to int/bool anyway.
 
It doesn't prevent operator overloading at all.
 
It does. <=> cannot return an arbitrary type in this design.
 
Unless you overload it with __spaceship
 
There's no way that two different ways to overload the same thing will pass.
 
That hooks into do_operator
 
7:03 PM
Would even be possible to know which would get called? Doubtful.
 
__compareTo doesn't overload the operator. It changes the behaviour that the operator invokes.
 
Will it get called when <=> is called?
 
Yes it will.
Will it be called in compare_function, no.
 
@rtheunissen How is that not operator overloading?
 
Okay I'll explain:

Imagine a hypothetical situation where we want to overload operators without restriction, and the RFC passed previously. We now have a __compareTo method but we want to overload the <=> operator. You can use __spaceship to change what logic the <=> operator invokes. But you haven't redefined natural ordering.
__compareTo is for defining natural ordering, which is what <=> currently points to.
The operators are not overloaded in this RFC.
 
7:08 PM
@LeviMorrison general operator overloading makes operators meaningless symbols
 
@Andrea Has worked well for Python and C++.
 
@LeviMorrison it makes for interesting error messages for << :3
 
I'm not against operator overloading at all. It's just not what the proposal is trying to achieve.
 
personally I would implement “operator overloading” in a similar fashion to your RFC
but uh, $x.__equals? why the . instead of ->?
 
@LeviMorrison consider the operator a pointer, that by default points to "compare". We are changing the internals of "compare", the pointer stays the same.
Operator overloading changes the pointer.
 
7:12 PM
I don't think very many will agree with you.
You are still changing the behavior of <=>.
 
@Andrea good spot, I'll edit for consistency.
Yes, that's right.
 
user1804599
declare(use_overloaded_operators = 0);
 
declare(i_opened_pandoras_box_by_suggesting_declare_strict_types="please don't suggest any new declare()s im really sorry")
7
 
@LeviMorrison indirectly.
 
I'm surprised there haven't been more questions about how this RFC works. Maybe people actually read the Application in Combination section.
 
user1804599
7:17 PM
Making == useful half of the time is an awful pitfall.
 
user1804599
It goes from never use to sometimes use and if you get it wrong it'll break horribly.
 
Agreed.
 
evenin
 
@bwoebi That's my impression as well. But it looks like cmb wants to sit on it until it becomes a moot point
 
> No, the methods are not restricted to instances of the same class. It is the implementor's responsibility to consider the definition of equality and ordering against other types. This also removes the inconsistency between internal and user-defined classes by providing a hook to the compare handler.
this is one of those things where there would be utility in allowing customisation, but it makes for a more predictable language not to…
the Andrea test: sure it's useful, but do you trust PHP developers not to hang themselves? :p
 
7:23 PM
Is there some way (besides triggering headers directly) to capture and prevent a library from sending a header? It's running in output buffering and causing an issue
 
Personally yes, with this i think we can.
@LeviMorrison would sorting an array of objects try to use an overloaded spaceship operator?
Of course not. It will always use the compare handler.
Even when you override the operator.
 
No, I suspect all userland code will and should use <=>.
It will not detect the prescence of __compareTo and call it conditionally.
 
@Andrea There are many things may be added using declare :)
<?php

declare(
    strict_types=1,
    strict_comparizon=1,
    scrict_properties=1,
    strict_variables=1,
    merged_symbols=1,
    function_autoload=1,
    const_autoload=1,
    trailing_commas_everywhere=1,
    end_statement_on_eol=1,
    compare_objects=1
);

namespace MyVendor\MyApp;
:D
 
If <=> doesn't mean "compare" then don't call the sort.
Ordinarily I'd try to root that out at the type level, but as you point out all objects are comparable by default anyway, so no use trying to prevent it.
 
@brzuchal noooooo
declare(comparison="<=>");
 
7:30 PM
come on, they look pretty
 
declare(java_mode=1);
 
mayne some build in autoload?!
 
I still don't like this bit:
> We should use either user-defined behaviour or default internal behaviour, not a mix of both. In this case, where __compareTo is not implemented, $a ⇐ $b should use only the default behaviour and not consider __equals at all.
 
    <?php // 2020
    declare(language="Java");

    import java.lang.*;

    public static class Main {
 
declare(psr4_autoload=__DIR__ . '/../../src/');
 
7:31 PM
If it has an __equals but not __compareTo I still think it should error.
It seems incredibly weird to write function __compareTo($b) { throw expr; }.
 
@Andrea That might be usefull :)
 
@LeviMorrison error by default if you compare? that sounds reasonable to me
 
@Andrea If and only if it has defined __equals but not __compareTo, yes.
 
@Andrea I'd vote yes to that
 
@FlorianMargaine now for declare(language="Haskell98"); and I can finally be happy,
 
7:35 PM
@Andrea Make PHP The New Shebang
 
declare(language="JavaScript");?????
 
declare(language="PHP");
 
@Tiffany that's crossing a line :P
 
@FlorianMargaine <?php declare(language="PE"); ?>ZM … This program cannot be run in DOS mode. …
 
7:38 PM
@Andrea I am tempted to flag it as obscene
 
@tereško please don't, would be unfair to subject StackOverflow mods to such profanity…
 
ah ... the "think of the children" argument :D
/me goes back to reading a book
 
@infinite_scream, the void
@NoraReed's true feelings. used to post less but then people apparently decided fascism was a great fucking idea
168k tweets, 44.1k followers, following 1 users
@Tiffany I've always dreamed of something like this.
but something more up to date.
 
@mega6382 looks like someone's master's thesis in postmodernism
 
lol, yeah
 
7:50 PM
(and I am only being slightly facetious)
 
reddit.com/r/PHP/comments/8xbunf/… ...this maybe isn't something to experiment with
 
we can always just start learning C#
 
@PaulCrovella yeah, I also thought about that. In one hand I can appreciate the intent, but on the other hand, it feels a bit like gaming the system
 
if feels like why the fuck would you put your vote in the hands of reddit?!
 
I think you might get better results leaving it up to 4chan
 
7:55 PM
@PaulCrovella Yeah, Reddit is like marijuana. Not illegal, but probably won't help you think better either
 
@tereško More consistent, at least
 
@PaulCrovella what would even be the point?
 
in that case you would at least get weaponize autism instead of weaponized lazyness
... ans SO is what you get, when you try weaponize "code reviews"
 
What would happen if we weaponized WebMD? Or Match.com?
Ooh, let's weaponize YouPorn!
 
@DanLugg that's like recommending someone to use DailyMotion
 
7:59 PM
@tereško Well, that's what I would recognize for low quality TV rips
Weapons of mass DMCA destruction!
 
@DanLugg you are a php developer, you should be supporting PornHub
 
@tereško I support wherever the keywords take me
 
@tereško damn right! lol
 
(and PornHub is objectively better in most ways anyhow, YouPorn just came to mind quicker)
 
well, here is the funny part: YouPorn and RedTube (if it still exists) got the name by bastardizing YoutTube. PornHub user "GitHub" for bastardization :D
 
8:03 PM
It is the site of community driven porn after all ;-)
 
anyway, back to reading a book
 
I was about to say; I haven't been here in about 11 months and in the first 3 minutes the conversation goes to porn.
 
you started it
 
8:21 PM
our electric bill for our main campus for last month is more than I get paid in a year
 
finally started watching Rick and Morty, gotta say, its really disturbing.
 
@mega6382 something something you're not smart enough to understand, or whatever that stupid argument is
 
@mega6382 I found it more obnoxious
 
I couldn't watch it because of the dribble under Rick's mouth, it disgusted me too much, and it doesn't go away.
 
oh, @DanLugg
long time no see
 
8:23 PM
@Tiffany No, I mean, I was at the scene where Mr. Jelly Bean is trying to r**e Morty and he says "just let it happen", and other instances like that.
 
@Tiffany Yeah, that too
 
lol
But in the end Rick killed Mr. Jelly Bean, so, I guess its ok. :P
 
no, it is not
it is retarded
 
8:31 PM
:43182323 bring folder home from work
 
good job, jeeves
 
lol, I moved the original message to the bin after making the reminder
I broke it
 
 
1 hour later…
9:34 PM
My parser will now accept this:
final class <K,V> BaseOuterIterator<T: Iterator<K, V>>
        implements Iterator<K, V> {}
It compiles it as if all of the <> stuff wasn't there, which is wrong of course. Gotta start somewhere.
 
Nice :)
 
it probably will take me a year to understand, how and when to use generics correctly
 
Heading home- later.
 
10:01 PM
@NikiC whatever cmb … I think it's time to just state facts (i.e. do a quick tally of in favors on the thread) and announce to start vote e.g. tomorrow or in two days - and just go ahead unless there's opposition.
@LeviMorrison I just strongly disagree about C++. No idea about py, don't get often to read it, but I find it terrible in C++ to learn/debug unknown code bases. If you're already familiar with a codebase, it's okay-ish
 
@bwoebi and possibly say it's for the RM to refuse to include the RFC if that's their choice.
 
@Danack yes.
 
s/refuse/object strongly/
 
@bwoebi I pretty much see people overload things in a sensible way. What goofy overloading code do you see (aside from the C++ standard << and >> for streams)?
Anyone know if there are downsides to doing this sort of thing in our parser?
 
@LeviMorrison equality overloads are sometimes really unexpected, even if they sort of make sense
 
10:07 PM
Variance:
                /* empty */
        |       "in"
        |       "out"
;
 
@LeviMorrison as opposed to defining tokens T_IN and T_OUT?
just note that these would be emitted as T_STRING by the lexer
 
Yes. I'm aware of the downsides to defining new tokens, I'm curious about these downsides.
 
unless you make the lexer context aware you can't really do that
 
Apparently it compiles fine but does not work ^_^
 
@LeviMorrison yeah, it's fine, the parser understands it, just the lexer never will emit a "in" string
 
10:11 PM
If I accept T_STRING here should I error in the compiler or parser?
 
you can't really accept T_STRING as it'll collide with types I guess?
 
In this context it shouldn't.
 
okay, then you'd error in the parser
as you're unable to build the AST for that
compiler erroring is for bad ASTs
 
Is there an example of doing such a thing in the parser currently?
 
@LeviMorrison what syntax are you trying to achieve?
 
10:14 PM
final class <K,V> BaseOuterIterator<out T: Iterator<K, V>>
        implements Iterator<K, V> {}
 
@LeviMorrison nah, it's all tokens
 
I can accept this, just need to make sure you can't do <hello T: Iterator<K, V> and such nonsense.
 
ah out for generics. Actually I think we'll need in / out rather sooner than later, when we allow for in or out references
 
Unless we can detect all reference usage at compile time we can't have that, I think.
How do you prevent reading from an out before it is written, or writing to an in?
 
@LeviMorrison an out reference would be simply written to at the end of the function.
 
10:18 PM
That seems really weird, honestly. And for the other issue?
 
And writing to an in can be prevented with a flag on the reference (which we anyway already check because types)
at least if typed props get in
 
@bwoebi So if you read it beforehand you read an undefined temporary variable?
 
@LeviMorrison yes
or we could just make it error
like typed props
 
Imagine a class type as an in parameter and you modify an object property. Any machinery for that in place either?
 
in is on values, not on contents of object containers
would be impossible to prevent that anyway
Now, I'm off to bed...
 
11:02 PM
yo
 
evening
finally remembered to bring my completed todo list folder home
 
Nice!
I'm doing bills. =/
 
11:24 PM
online bill pay <3
my electricity would probably be shut off if it weren't for online bill pay
well, shut off, then turned on... repeat several times
 

« first day (2823 days earlier)      last day (2107 days later) »