« first day (3667 days earlier)      last day (1287 days later) » 
00:00 - 19:0019:00 - 23:00

7:00 PM
I'm just concerned about too many "if X, then not Y" feature implications, as that's where it gets complex to implement, argue for, and document/explain.
 
@IluTov or don't allow casts, but do allow non-magic toString, toInt methods...?
 
@Danack Sure, all non-magic methods will be allowed. The question is, do we need implicit conversion from an int-backed enum to int, for example. If so, what about manual casts ((int) $foo). This is already valid code (although it does warn). The two should probably likely result in the same value but object to int casts right now always evaluate to 1.
If it were me I'd just avoid implicit conversion altogether but that does remove some convenience.
 
also avoids Ocramius ranting about things...
well, fewer things.
 
7:17 PM
$heart = Suit::Hearts;
strlen($heart); // '1' in weak mode, TypeError in strong mode?
That's what a class with __toString does right now.
 
Yeah but a string-backed enum has potentially two different string representations...
As __toString and ->rawValue() return potentially different values.
 
So... we could say that this:

enum Suit {
case Hearts('H');
}

Is just a syntactic short-hand for this:

enum Suit {
case Hearts {
public function __toString: string { return 'H'; }
}
}

Which then means if you have both, the explicit method wins you moron. But then we are implicitly saying that we have to implement __toInt() and__toFloat(), at least for enum cases.
 
But Suit::Hearts === 'H' would evaluate to false, right?
 
Right.
 
7:23 PM
I think overall, the more we can fall back on "this is syntactic sugar for this other thing that already has all the edge cases worked out", the better off for everyone.
 
Sounds like a workaround for primitives, imho
You'll need to type cast it to be able to compare those values
 
Yes, which is fine. If you just want a named primitive, use a constant.
 
@Crell Why do we need __toInt and __toFloat? Maybe __toString should just be forbidden for string enums.
 
The use case here is wanting to work with an enum as far as the type system is concerned, but still having easy round-tripping to a database.
@IluTov Possibly, but then we need to define all the various casting and strict/weak behavior. "The same as __toString, right or wrong" at least gives us something to not bikeshed.
 
@BogdanUngureanu Depends, Suit::Hearts == 'H' could still return true.
 
7:27 PM
Unless you can implement "all the same behavior as __toString but not using __toString", and copy that for int and float. If you feel those can be made parallel I'm OK with that implementation detail.
 
@IluTov I would avoid it, personally because Suits::Hearts == 0 would evaluate to for example
And I don't think it's a good idea to encourage weak comparisons because it's more handy than manually converting those values
Oh, fudge, forgot about the comparison changes. :D
 
Do we even want to think about how bitflag enums would fit into this, or leave that to "define your own damned primitive values and go away"?
 
Literal types maybe? :D
 
7:42 PM
Wouldn't help with that. :-)
TypeScript:

enum FileAccess {
    // constant members
    None,
    Read    = 1 << 1,
    Write   = 1 << 2,
    ReadWrite  = Read | Write,
 }
 
Stupid question: aren't we trying to solve too many things with enums?
Maybe some things could be left to userland to implement
 
Wes
@PeeHaa any software i could use to make voice sound like it's coming from a robot?
not as in poor tts software :P
like with high mid range or something
distorted
 
@BogdanUngureanu But in that case, we should have implicit coercion nowhere. Nowhere/everywhere is better than only some of the time because then you have to remember when it'll work.
 
@BogdanUngureanu We have to give them enough things to implement from. So far, everything we've described is already in enums in some other language. They pack a lot of functionality, especially in Swift/Rust/Kotlin.
I think we can do without direct binary enums, though. That's easy enough to emulate with primitive literals.
 
@Wes There are a few things that people use streaming... but I cannot remember what they are off hand. Let me see.
 
Wes
7:55 PM
must sound kinda fun
 
8:10 PM
@IluTov I think I assumed that enums might be primitive values, so I assumed the typing would be structural instead of object based.
Am I wrong? :)
so let's say that we have a function like getSuit(Suit $value) {} a call with getSuit("h"); would actually give a TypeError, right?
 
@BogdanUngureanu In our RFC enums are object based, same with primitive-backed enums. Whether we coerce the primitives into objects and vice versa is not clear yet. If it were just me I would not.
@BogdanUngureanu That's the question. Usually PHP does implicit coercion unless you enable strict types.
 
Got it, I think that at some point there were some discussions to also support primitive based values
 
@Crell Another issue with __toString in string-backed enums. You're saying __toString has precedence when converting an enum into a primitive. But what about the other way around? We can't use __toString when converting primitives into objects.
 
Excellent point.
@BogdanUngureanu If we want enums to have method support, they have to be objects. The question on the table at the moment is how to handle enum cases that have a natural and necessary primitive equivalent. How/when should they be translated back to that primitive? Upcasting is easier. Suit::from($one_of_the_literal_values_or_error).
 
::from would be a method implemented in userland?
 
8:26 PM
@BogdanUngureanu from/to would be synthesized automatically in primitive-backed enums.
@Crell Another thing: Normal enums implement __toString and just return the name of the case, this would make __toString of non-string-backed enums and string-backed enums different.
 
No, an automatic method on primitive-backed enums.
 
would it make sense to return the value passed to the "from" method?
 
@BogdanUngureanu Suit::Hearts === Suit::from('H');
@IluTov I figured we would skip a default __toString() on non-primitive enums then. It's a singleton object, period, kthxbye.
 
@Crell Then we'd still have a discrepancy between primitive-backed and string-backed enums.
 
... Aren't string-backed enums a primitive-backed enum...?
enum Suit {
  case Hearts;
  case Diamonds;
}
// No primitive equivalent at all, no from(), no __toString(), nothing.
 
8:30 PM
yeah yeah, "non-string-primitive-backed enum" was just a mouthful
 
(Unless you write your own __toString() method, in which case it's an object with a __toString and behaves accordingly.)
Discrepency how?
 
Well, what does (string) Suit::Hearts return? (if you assume it's backed by constant 0)
 
I... would assume Suit::Hearts turns into int(0), which is then cast to "0". Or it would TypeError.
 
@Crell So, never auto-generate __toString then? That's fine by me.
 
The only reason to auto-generate __toString would be to ensure cases always have a primitive version. If we don't care about that, then it's not needed.
The alternative would be to auto-generate one that is the enum's stringified name, but... then we need to not do that for enums that have any associable cases.
 
8:35 PM
@Crell At the moment the RFC mentions __toString returning the name of the case. I'm ok with scratching that altogether.
It wouldn't be a good human readable representation anyway.
 
In my mind, we can have 2 "modes" or 3 "modes". 2 mode: Always generate a __tostring, which defaults to the case name, so all enums are always string-backed unless they're associable. 3 modes, there's no primitive-backed equivalent unless you explicitly say so.
But since from() only makes sense if all cases have a primitive equivalent, that pushes me toward 3 modes instead of 2. And saying that, I realize that's dumb because Suit::from('Spades') would still totally work. :-)
 
Wes
@StatikStasis hmm, they look a bit dodgy
like "here's our free* video converter"











*with some adware
 
@Crell Just because an enum implements __toString doesn't mean it needs to be string-backed.
As in, we can implement __toString without implementing from/to and vice versa.
Objects with __toString currently coerce to string without warnings. Maybe we shouldn't even auto-implement __toString at all.
 
8:51 PM
If we don't use it for explicitly string-backed cases, then I agree it doesn't make sense to use it anywhere by default.
 
9:04 PM
Incident on 2020-10-30 21:04 UTC ・ API Requests has Partial Outage
 
9:22 PM
@Crell do you have an updated version of the RFC? :) Tbh, I'm really confused on what enums would actually support. :)
 
I have the file open to update now, but I'm distracted by the day job so it will take a bit of time to update for this conversation. :-)
(We're working in a separate github repo for now, will port back to the wiki site eventually.)
 
Thanks, tbh still do think there's some added value to literal types (especially for people that are into structural typing). Some could use enums for nominal typing while others would like a more structural approach :)
 
WTB 1x[weekend] PST
30 minutes
 
One does not simply buy a timezone otherwise I'd have MST ... or Mark Snoozing Time
 
Hmm. Are there GC flags for "never collect this thing, seriously, I mean it"? Like if I made a zend_string in an arena? @NikiC
 
9:30 PM
@MarkR PST = please send tell in MMO lingo, which I haven't used in a couple years
 
Is there any way to have phpstorm windows "sleep" when not being used for a while? I always keep windows open for all the projects I work on throughout the week but there are a lot, and some I don't touch for a couple days. I don't wanna close them but I also don't want them taking up resources
 
While in store, how to change terminal colors (especially for errors ) in Darcula theme? Anyone (too)?
 
@Alesana Doubt that, that would need some kind of per project hibernation (storage/persisting and obviously reload time and coherency checks when reactivating) which is hard to justify in complexity and all.
There is a Powersave mode tho.. but it's probably all or none
 
@Tiffany You and your fancy young-un lingo
 
@makadev As far as storage/persisting if you're in the middle of an action or need our terminal history or something I could see that being required, but I would even be fine with it closing it altogether since it does auto save anyways
But keeping that window as a marker
Then when the window is opened back up it would open the project back up. I guess in reality that seems pretty pointless though
When I can just close it and reopen it with a few extra steps
 
9:44 PM
@LeviMorrison interned?
 
@NikiC Thanks.
 
@Alesana At least it sounds pretty special, you want to use your OS Task-switcher to handle Project switching or a visual reference or is it more like a Bookmark for fast switching to the most recently used stuff?
 
More like a bookmark, not necessarily for most recently used but just for projects that I know I will be using regularly. There doesn't seem to be a way to bookmark projects with it
 
@Alesana Isn't open recent project enough for what you want?
Unless it decides it needs to index it's pretty much instant switching between projects
 
@PeeHaa Not necessarily. I would like to keep projects there that I may not have actually opened in a while
Just like, all the projects that I work on where I work
 
9:53 PM
Are you really working on that many projects at the same time? :P
 
Some 15 services :p
The joy of microservices
 
Most recent shows 50 projects for me
It doesn't for you?
 
Mine is 33. I suppose that it would work but I would prefer to have them all organized and in the same spot, without other test or open source projects mixed in. Like I said in reality it seems pretty pointless and arbitrary when I can just do that :P
 
:D
 
33.. 50... here I have 3.. xD
 
9:58 PM
I would say that's a good thing :)
 
@Alesana maybe there is a plugin for you liking, having some shortlinks/bookmarks for project doesn't see tooo unreasonable. Worst case you just need to make a directory with shortlinks.
 
Yeah in my recent projects I am seeing only like 70% of the services that are encompassed by my project
But anyways, it doesn't matter anymore because my project was put on an indefinite pause 🙃
 
To the Magento 1 machine!
:P
 
All issues have been resolved!
 
Well not all @Jeeves as can be seen above
 
10:02 PM
Well Magento 1 does solve my issues of too many projects
We have 100+ sites all on the same project
 
so, like, in the same way as shooting yourself in the head would solve the problem
 
@IluTov Thoughts on primitive-backed cases having an Enum::map() method that returns a primitive->Enum associative array?
I figure someone's going to ask for it.
And... it probably would be useful for things like select boxes.
 
@Crell I would argue that belong in the reflection API somewhere
 
Oh god, we haven't even talked about reflection yet. Other than the reflection API seems to be designed to be as clumsy to use as possible. :-)
 
yeh and it tends to be expensive af as well, and I am inclined to agree that it's a reasonable/sane operation
but semantically I think it is a reflection task
imho, ymmv, etc etc
 
10:08 PM
In the pure sense, I'd probably agree. As a practical matter, it's common enough that I don't think forcing people into a 6 method chain of fugly just to build that list is a good idea.
 
@DaveRandom Pretty much
I just counted them, the 100+ was a pretty big exaggeration
It's 493
 
@Crell (new ReflectionEnum(Name::class))->toArray(); I could live with, but also you are problably right
 
Hm.
That... is not so bad. And reflection is actually faster than you think, last I checked.
Assuming we added a toArray() method.
 
well it's presumably dependent on the symbol as well, to say "reflection is slow" is very simplistic because differnt reflection task require different expense (obviously), so just creating an instance and then copying a hashtable to an array can be fairly free-ish
I think the issue with reflection is (was) that it used to collect a load of data on construct instead of on access
the actual process of retrieving data from the class table or whatever isn't particularly expensive
 
Oh project bookmarks do exist
Or, "Favorites"
Oh wait nvm
That's bookmarks within a project
 
10:21 PM
@IluTov github.com/Crell/enum-comparison/pull/25/files - For your consideration.
 
The list function doesn't have one the other way? or did I miss something? Well, can a scalar backed value be duplicated or is it exclusive. I'm assuming exclusive? But ive only skimmed
 
10:38 PM
@PeeHaa yo, another PR has been made.
 
@Crell I agree with @DaveRandom that this should probably go into the reflection API. I think for the same reason we probably don't need __toString.
@Crell Thanks, I'll review it out tomorrow. My brain is too tired right now :)
 
OK.
@MarkR The other way means an array with object keys, and I'm not getting into that. :-)
 
That means you won't be able to do an enum map to English without going through a primative mapping step
 
If you want an English name for each, put a label() method on it and use that. Then you can just use $list[$key]->label()
/me has to head out for the night. Talk more tomorrow.
 
I'd think:

$foo = [
AccessEnum::BASIC => 'Basic',
AccessEnum::ADVANCED => 'Advanced',
AccessEnum::BLAH => 'Something Else'
];
 
10:46 PM
But the ones on the left are objects. Objects can't be array keys.
/me skedadles.
 
That was kinda the point... going to be pretty limiting if you can't use scalar backed enums in something as simple as an array.
 
@PeeHaa its on the so chat driver repo, i was wondering if you could add the tags to the PR, as tomorrow is the last day for the submission. :)
 
@Crell My tired brain changed its mind. ^^ I'm reviewing it now.
 
00:00 - 19:0019:00 - 23:00

« first day (3667 days earlier)      last day (1287 days later) »