Re: [RFC] ifsetor operator

From: Date: Fri, 16 Apr 2004 19:56:04 +0000
Subject: Re: [RFC] ifsetor operator
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-9273@lists.php.net to get a copy of this message
Marcus Boerger wrote:
[RFC] ifsetor operator Synopsis: "ifsetor" "(" value "," default ")" Returns the value if it exists or a given default value. Syntax: "ifsetor" "(" variable [ "," expression ] ")" Semantic: - The value in question must be a variable.
I'd prefer to not have this restriction, a return value from a function call should be fine. I'd make this any expression.
- The default value can be any expression. - The default value can be omitted in which case NULL will be used.
I'd also propose to extend this to a whole list of expressions: "notnull" "(" expression [ "," expression ]* ")" This would return the first expression which is not null. If all expressions are null then null is returned. I'm not too happy with "notnull" as a name, better suggestions are welcome :-) Just brainstorming: An other idea would be an operator like "|||": $a = $a1 ||| $a2 ||| $a3; (I didn't call it "err" or "//" to not get flamed *as* badly ;-)) - Chris

« previous php.internals (#9273) next »