Re: sapi_header_op

From: Date: Mon, 01 Jul 2002 04:09:06 +0000
Subject: Re: sapi_header_op
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-85690@lists.php.net to get a copy of this message
At 10:03 PM 6/30/2002 +0200, Sascha Schumann wrote:
On Sun, 30 Jun 2002, Andi Gutmans wrote: My only problem with this patch is that I don't like API's which pass around structs. I always find it cumbersome to have to create and fill the struct and then pass it. Can you think of something similar without using structs?
    If you look at the main body of the function, you will see a
    number of variables which script authors might want to
    overwrite in the future.
    Everytime an addition occurs, the main interface would have
    to change.  You might end up with something like
        sapi_add_header12("Test: X", 7, 1, 0, 404, 8372383, 123,
            "", "utf8", "filter_code", 0, -1);
    We are almost half way there.
    With the new interface of sapi_header_op(), we won't have
    this problem.  It will continue to exist unchanged,
    regardless of how many variables it might accept.  Extension
    developers will be happy about this, because it avoids BC
    issues.  The interface is also less bug prone because of its
    improved semantics.
    And thus, I conclude that passing in a struct is the most
    versatile way for this kind of API.
I understood the rational of using a struct from the beginning. I still in general don't like using structs very much because as I mentioned it's not as easy to use. I prefer having 2-3 methods then having one method which I need to pass a struct to. (There is the option of var_args btw, but I agree that that is probably a worse option). If enough people think this change is a good thing then go ahead and commit it. It's no as if I think this is the end of the world. Then again, I'm sure we can work out the 2-3 function prototypes we need which would do the same and would be easier to use. Andi

« previous php.dev (#85690) next »