« first day (3522 days earlier)      last day (1433 days later) » 

12:05 AM
I messed a little bit with woocommerce during an application process for a job, it's alright... about what you can expect from a WordPress plugin
But it is a higher quality WordPress plugin at least
 
12:40 AM
@ignacioSpisso They are both turds in their own way
ohai @DaveRandom o/
 
I am also a turd, in numerous ways
/me really sleeps
 
 
2 hours later…
2:48 AM
Wrong display ・ Website problem ・ #79680
 
3:05 AM
I've got a problem I don't even know how to start troubleshooting:
I sent a request through postman. It authorised fine, 204 response. (No content) I can verify that it was received.
I exported the code using PHP - HTTP_Request2. I ran the code. It authorises fine, but the response is now 400 (Bad request)
I don't even know how to start troubleshooting this. Is there a way to view both requests side by side so I can look for differences?
I'd post this as a question, but I can't even recreate a simple enough version of this error to be worth writing a question for without getting downvoted to hell.
 
 
6 hours later…
8:47 AM
@JonathonPhilipChambers I'd start by just analyzing the code that returns the 400 to see what's going on. If you have a staging environment you could also see if you can reproduce it there. It's very hard to say without seeing the actual code.
 
 
1 hour later…
cmb
10:00 AM
@ignacioSpisso you need to update PrestaShop to the latest 1.7 (see github.com/PrestaShop/PrestaShop#server-configuration)
@Tiffany known issue (bugs.php.net/bug.php?id=79663)
 
10:35 AM
morns
 
11:20 AM
@cmb heh
 
11:35 AM
Morngins
 
Morgen
 
cmb
11:49 AM
moin
 
Is somebody actively working on algebraic data types? If not that's something I'd like to do for PHP 8.1.
Which makes me wonder, should we make enum a keyword in PHP 8?
 
12:25 PM
feasgar math!
 
@IluTov yes, imo.
 
@IluTov The problem with enum is likely going to be semantics.
Will a enum typed argument check for the right values?
 
Levi has probably done the most deep thinking about enums and the work for an implementation.
@Derick picking an uninformed answer out of thing air; no. That info should be attached to the zval, so that you can just check the type rather than having to check values.
which means you have to do some wrapping of the string -> enum when you want to use one, but that's a lot saner than having value checks in chains....
 
@Danack Agreed. Enums should have a different runtime representation and not just be syntactic sugar over constants.
 
posted on June 06, 2020

I’ve spent the entire week watching video after video after video of police viciously attacking minorities, unarmed peaceful protesters, bystanders, and members of the press. Again and again and again. If you’re on the fence about which way to lean… if you kinda feel like there are problems on both sides… please take some time out of your day to randomly scroll through what is trending on

 
12:29 PM
I'm not even sure we should allow casting enums to ints. If you really need that add a getRawValue() method to the enum.
 
@LeviMorrison are your notes/thoughts/possible implementation for enums available anywhere please?
@IluTov yeah.....I think that was one of the things holding it up. some people expect certain things from enums as they exist in other languages, including converting them to scalars, but they aren't all necessary....but I only just remember a few snippets of the conversation and Levi is your man for this.
 
cmb
There is an old enum implementation by @bwoebi: github.com/php/php-src/pull/1698. Biggest issue with this is BC (see github.com/php/php-src/pull/1698#issuecomment-167630201). Not sure if we could do this for a minor PHP version (not even sure about a major version).
 
12:56 PM
Is there anything else other than enum that probably needs to be reserved? maybe 'type' ?
 
@Danack Possibly let or some other keywords for pattern matching (to extract values from algebraic data types)
match ($result) {
    let Result::Ok($val) => ...,
    let Result::Error($error) => ...,
};
@Danack Making enums objects under the hood would be quite convenient (free type checks, free method calls, interface implementations, etc). If they are immutable ref/value typing shouldn't matter. The only concern (that I can think of right now) is the performance penalty.
 
@cmb I do not really see this as a major concern, but opionions may vary…
 
(I meant to respond to @cmb)
 
fyi, you can edit that.
Aug 9 '19 at 19:32, by Danack
I've said it before, I'll say it again. I wish Stackoverflow had focused on a chat app five years ago, instead of focusing on more questions and answers, and the silly documentation idea.
 
cmb
Problem are external extensions (PECL or private). These are often slow to catch up with core changes, and in this case it may go unnoticed (if no catching default case on switch). And yes, performance
Performance of objects may be bad.
 
1:36 PM
my preference for enums is definitely immutable objects, with a bit of magic to allow them to be used as constants etc
they should have no underlying value, only identity (my go-to example is that Weekday::MONDAY == Month::JANUARY should have no possibility of returning true)
 
@IMSoP That's a really good example. And once you attach values to enum cases the underlying type itself does not accurately describe the enum value as a whole.
 
my gut is that 99% of uses wouldn't actually need to look up the object's details, they would just do a direct pointer comparison, because all references to the same enum value would be references to the same singleton object
 
@IMSoP That would not work for Result::ok(10) === Result::ok(10) so we likely need to touch ===.
 
@IluTov I think algebraic types and enums should be separate features
I can see the temptation of combining them, but to me, the whole point of an enum is that it has a closed set of values, not just a closed set of sub-types
 
@IMSoP As in separate RFCs or separate things? Definitely not separate things IMO because algebraic data types are pretty much an extension of traditional enums.
@IMSoP Many new languages combine them which makes sense if you ask me.
 
1:43 PM
I've not used any languages that do, but I find combining them confusing
to me, Result::OK is a fundamentally different concept from Result::ok(10)
 
@IMSoP Additionally, algebraic data types will also need to allow cases without values
enum Option {
    case Some($value);
    case None;
}
So if you need to attach a value to any of the cases you'd need to convert it from an enum to an algebraic data type, which seems weird.
 
why is that weird? they're different things
if you combine them, you have the opposite problem, of needing notation to attach immutable data to cases
(one sec, just digging out an example)
so this is the kind of thing I'd like to do with enums: gist.github.com/IMSoP/47488b87412ae4e2b1719d7e3a818c7d
roughly speaking, each case creates a singleton instance of the class, passing the parameters to the constructor
whereas with algebraic types, you want to define distinct constructors for each case
 
@IMSoP Why not just this? gist.github.com/iluuu1994/b6614f2db0b1f6e733638e0fc972da4b I don't think enum should be allowed to define other fields.
 
@IluTov don't we need Intersection and Negation of types to have algebraic types?
Or am I confusing this with something else?
 
@IluTov it just eliminates the need for loads of switch/match statements everywhere
 
2:02 PM
@Girgias Can you elaborate? I don't follow.
@IMSoP True but given that enum values are supposed to be immutable allowing custom properties does not feel right to me.
 
Well maybe I'm just confusing stuff, but how I thought Algebraic types work is that you consider types to be sets, so to be able to use them fully you need to be able to take the Union (which we have in PHP 8.0), the Intersection and the Complement(/negation) of the set represented by the Type
 
@IluTov they're still immutable, they just have internal values; in some languages, they're expected to have exactly one value (often an int, which I hate); Swift has the concept of "Raw Value" docs.swift.org/swift-book/LanguageGuide/Enumerations.html
here's an example of how much boilerplate it can save: gist.github.com/IMSoP/c17854a20ee2aebd208d1e8c827e3d9e
the saving scales proportional to number of cases times number of associated values
 
@IMSoP The raw values in Swift represent the case. The $startIncluded and $endIncluded properties are additional information of the given case. So I wouldn't say it's the same.
 
it's just a generalisation of the idea, though
for many enums, you don't want any "raw value", they are just themselves
but if you're allowed to associate one integer or string with a case, why not two?
 
@IMSoP But you're probably not really doing that. If you were to create a case with the same parameters, those two would probably not be equal, right?
So, there's still an underlying identity of each of those cases.
 
2:13 PM
sorry, what do you mean?
 
enum Token {
    case WHITESPACE(true);
    case COMMENT(true);
    case IDENTIFIER(false);

    public function __construct(private bool $ignored) {}

    public function isIgnored(): bool
    {
        return $this->ignored;
    }
}
@IMSoP Simplest example I could think of. Just because whitespace and comment both are ignored (or whatever you wanna call it) doesn't mean they are the same value.
 
OK, and what's the problem?
 
so there's still an underlying raw value
 
sure, the value is Token::WHITESPACE or whatever
I think languages that force each case to have a "real" value of type int, or string, or whatever, are leaking implementation details
 
But then why: "but if you're allowed to associate one integer or string with a case, why not two?"
 
2:17 PM
because to me, the value you're associating is already extra data
 
There's no need for that, if each case has it's own raw value anyway
btw when I say raw value i don't mean it should be exposed to userland. it's just what PHP uses under the hood to differentiate between those cases
@IMSoP but it's not really extra data since the data is always the same for each case, it's more of an optimization. If you were to serialize the enum case you wouldn't want to store that information as it is completely useless.
 
right, the raw value is a C pointer somewhere in the zval
@IluTov sure, it's all just sugar
serialization would need to be overloaded anyway to ensure immutability (it would need to find the current pointer to that enum case, not re-run the constructor)
serialization based on a user-specified "raw value" is not needed for that, just use O:Token:WHITESPACE (or whatever the syntax is), which is much less likely to be accidentally broken
 
Hi, how can I install the commerce module for drupal, via composer? I installed composer but Im stuck
Do i need to install it in the modules folder?
 
@ignacioSpisso On what step you failed?
 
I tried to install the module but, manually downloading the package but then I read that it must be done only via composer
 
2:28 PM
@IluTov incidentally, Java allows exactly the style of enum fields I'm describing; see the Planet example here: docs.oracle.com/javase/tutorial/java/javaOO/enum.html
 
@ignacioSpisso Is that answer itself?
 
@IMSoP Ok, but then you still need a bunch of safety checks to make sure those properties cannot be mutated after construction, specially if all cases are shared across the whole application.
 
I dont know how to install it
 
@IMSoP I see, I didn't know Java does that. Still doesn't feel right to me.
 
@IluTov yes, ideally immutable objects would be a pre-requisite; although, "just don't mutate them if you don't want headaches" would also be fine with me
if someone wants to abuse it with enum Foo { ... public $counter ... }; Foo::Bar->counter++; then is it the language's job to stop them?
 
2:31 PM
@ignacioSpisso Follow this manual page from top to the bottom. Step by step. If something is failing it is because you tried to override with some 'manual' methods by yourself so my best guess would be to start over.
 
yeah I already deleted the package i unzipped
 
@IMSoP Anyway, getting back to enums vs ADTs, I think the premise that "with algebraic types, you want to define distinct constructors for each case" is wrong. Take the token example above. Some tokens will attach additional information (the identifier string) but all of them will still need to specify if the token is trivia or not.
 
but now I dont know what path should i choose
 
@IluTov but that's an enum example; take the Option example you posted here: chat.stackoverflow.com/transcript/message/49575775#49575775
the Some case needs a one-parameter constructor, the None case a zero-parameter one
 
@ignacioSpisso You should always execute terminal commands from root directory. One where composer.json and vendor directory are.
 
2:34 PM
ok
 
@ignacioSpisso it sounds like you need to hire a developer, or find some tutorials on how to achieve what you want to achieve. We aren't going to be able to guide you all of the way through what you're trying to do in this room.
 
@IMSoP The point is that with IDENTIFIER you want to store the name of the identifier as a string.
 
im a developer lol
 
I don't see how that example is an algebraic data type rather than just an enum
 
enum Token {
    case identifier(string $name);
    case whitespace;
    case comment(string $comment);
}
 
2:35 PM
right, so now we're back to different constructors - identifier takes a parameter, but whitespace doesn't, and comment does but uses a different field name
and we can no longer compare by identity, which to me is what a "true" enum allows
 
@IMSoP right but now if you want to also specify if the token is trivia the thing falls apart.
 
indeed, which is why I think overloading enum for both concepts is problematic
.
I think algebraic types are better expressed as something like sealed classes
 
@IMSoP Not really, it only doesn't work if you implement it through custom constructors.
 
well, it's all just sugar either way
if you really wanted to you could combine them: gist.github.com/IMSoP/a98e33c71f72f9a2c0a44c912540cc94
I guess part of my hang-up is that I think in OO a lot, so having to write every method as a switch/match just feels weird to me
even more so with an algebraic type, where each branch may actually have completely different fields available to it
 
3:02 PM
a sealed class equivalent would be something like this: gist.github.com/IMSoP/0d180555dbc1f78741bd8bbe30bbce1b which feels more natural to my OO background, but I suspect less so to someone with more FP experience
 
Is there someone that really can help me install, drupal commerce via composer?
 
31 mins ago, by Danack
@ignacioSpisso it sounds like you need to hire a developer, or find some tutorials on how to achieve what you want to achieve. We aren't going to be able to guide you all of the way through what you're trying to do in this room.
 
looking at that I guess the key difference is that OO encourages you to group different behaviours of a particular type, whereas FP encourages you to group different types for a particular behaviours
@ignacioSpisso are you following the instructions that Tpojka linked?
I see that one of its tips is "Composer commands are always run from the site root (mystore in this case)." does that answer your question about "what path should I choose"?
 
3:45 PM
@IluTov musing on a few different ways the two types of data could be combined: gist.github.com/IMSoP/2082f2abe76d562c3b0ee258be15f1d6
in the end, though, you still have the fundamental difference that an algebraic type needs the concept of "instances", so you can't just compare by identity, serialize by name, etc
enums which aren't required to be a proper subset of algebraic types feel a lot easier to implement and optimise in my mind
 
 
2 hours later…
5:25 PM
@Danack I think @bwoebi has an impl of enums somewhere
 
5:42 PM
@IMSoP Thanks. I'll compile a list of languages and how they do enums / ADTs.
@NikiC Can I find the slides of your talk yesterday somewhere?
@SebastianBergmann I'd be interested in yours too, I just had a discussion on mocks with a colleague last week.
 
 
1 hour later…
6:52 PM
I doubt that is gonna be of interest to you ;)
 
hi
 
7:22 PM
@NikiC thanks! Why not? xD
 
@NikiC I might steal some of that for Dutch PHP Conference if that's OK?
(only the ideas, not the code)
@NikiC How BTW, can we do stubs for (shared) PECL extensions?
 
@Derick sure
@Derick yeah
But you need to be careful with what the types you use in them depending on your minimum supported PHP version
 
7:37 PM
Question wasn't "Can we", but "How can we" :-)
 
@Derick Same way as in core. The script is copied by phpize
 
ah
 
And I believe also integrated in the pecl build system
 
 
2 hours later…
10:09 PM
you also just use the script from php-src on the stub file in your extension, that worked for me
php8.0 build/gen_stub.php /my/extension/stub.php
 

« first day (3522 days earlier)      last day (1433 days later) »