Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-13 Thread Antony Dovgal
On Tue, 13 Jul 2004 09:12:19 +0200 (CEST)
Derick Rethans <[EMAIL PROTECTED]> wrote:

> On Mon, 12 Jul 2004, George Schlossnagle wrote:
> 
> > what was wrong with nvl() (of oracle fame)?
> 
> Nobody else but oracle people have any idea what they expect when they
> see nvl().

Agree.
Moreover, it's too obscure to understand.

I vote for default() or default_value().

(Actually I vote against such construct at all, but it seems that
nobody listens to such votes).

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED] || [EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-13 Thread Derick Rethans
On Mon, 12 Jul 2004, George Schlossnagle wrote:

> what was wrong with nvl() (of oracle fame)?

Nobody else but oracle people have any idea what they expect when they
see nvl().

Derick

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Marcus Boerger
Hello Andi,

  wow i didn't remember seeing that. So with default being a
reserved word to me it seems like one of the best choices.


  
Monday, July 12, 2004, 10:01:47 PM, you wrote:

> It's a reserved word so I doubt it'll break scripts.

> Andi

> At 05:37 PM 7/12/2004 +0200, Marcus Boerger wrote:
>>Hello Derick,
>>
>>Monday, July 12, 2004, 11:21:06 AM, you wrote:
>>
>> > On Mon, 12 Jul 2004, Sebastian Bergmann wrote:
>>
>> >> Andi Gutmans wrote:
>> >> > How about default($var, expr)?
>> >>
>> >>   It might be a good idea to decide on a name for the construct before
>> >>   the PHP 5.0.0 release in order to make it a reserved word (marked for
>> >>   future use).
>>
>> > Agreed, and I also like default()
>>
>>The problem with default() is that there will be tons of scripts out there
>>that will be broken by this. Hence i'd like to see a more non intuitive
>>name (like the ifsetor). Probably getvalue() was the best compromise so
>>far.

-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Andi Gutmans
It's a reserved word so I doubt it'll break scripts.
Andi
At 05:37 PM 7/12/2004 +0200, Marcus Boerger wrote:
Hello Derick,
Monday, July 12, 2004, 11:21:06 AM, you wrote:
> On Mon, 12 Jul 2004, Sebastian Bergmann wrote:
>> Andi Gutmans wrote:
>> > How about default($var, expr)?
>>
>>   It might be a good idea to decide on a name for the construct before
>>   the PHP 5.0.0 release in order to make it a reserved word (marked for
>>   future use).
> Agreed, and I also like default()
The problem with default() is that there will be tons of scripts out there
that will be broken by this. Hence i'd like to see a more non intuitive
name (like the ifsetor). Probably getvalue() was the best compromise so
far.
Best regards,
 Marcusmailto:[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Marcus Boerger
Hello George,

Monday, July 12, 2004, 6:36:22 PM, you wrote:


> On Jul 12, 2004, at 11:37 AM, Marcus Boerger wrote:

>> Hello Derick,
>>
>> Monday, July 12, 2004, 11:21:06 AM, you wrote:
>>
>>> Agreed, and I also like default()
>>
>> The problem with default() is that there will be tons of scripts out 
>> there
>> that will be broken by this. Hence i'd like to see a more non intuitive
>> name (like the ifsetor). Probably getvalue() was the best compromise so
>> far.

> what was wrong with nvl() (of oracle fame)?

In oracle it means Null-VaLue replacement. But we are providing a default
in case a variable is not set. But anyway from my side this would give a
good name, too (for No-VaLue) in the same manner coalesce would work for
the other behavior mentioned in this thread.

Best regards,
 Marcusmailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Jason Garber
>>
>> The problem with default() is that there will be tons of scripts out
>> there
>> that will be broken by this. Hence i'd like to see a more non intuitive
>> name (like the ifsetor). Probably getvalue() was the best compromise so
>> far.

GS> what was wrong with nvl() (of oracle fame)?


ifset()
ifsetor()
setor()

are 3 short, "construct" sounding, meaningful names to consider (they have all been
mentioned before).

-Jason

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread George Schlossnagle
On Jul 12, 2004, at 11:37 AM, Marcus Boerger wrote:
Hello Derick,
Monday, July 12, 2004, 11:21:06 AM, you wrote:
Agreed, and I also like default()
The problem with default() is that there will be tons of scripts out 
there
that will be broken by this. Hence i'd like to see a more non intuitive
name (like the ifsetor). Probably getvalue() was the best compromise so
far.
what was wrong with nvl() (of oracle fame)?
George
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Marcus Boerger
Hello Derick,

Monday, July 12, 2004, 11:21:06 AM, you wrote:

> On Mon, 12 Jul 2004, Sebastian Bergmann wrote:

>> Andi Gutmans wrote:
>> > How about default($var, expr)?
>>
>>   It might be a good idea to decide on a name for the construct before
>>   the PHP 5.0.0 release in order to make it a reserved word (marked for
>>   future use).

> Agreed, and I also like default()

The problem with default() is that there will be tons of scripts out there
that will be broken by this. Hence i'd like to see a more non intuitive
name (like the ifsetor). Probably getvalue() was the best compromise so
far.

Best regards,
 Marcusmailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Derick Rethans
On Mon, 12 Jul 2004, l0t3k wrote:

>
> "Andi Gutmans" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > How about default($var, expr)?
> my only reservation is that "default" is already part of a language
> construct :

...

> i'd say use defaultvalue

Too long IMO.

Derick

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread l0t3k

"Andi Gutmans" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How about default($var, expr)?
my only reservation is that "default" is already part of a language
construct :


switch ($param = $_GET["param"]) {
case "foo" : bar(); break;
case "this" : that(); break;
default:
the_other( default($param) );
}


i'd say use defaultvalue

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-12 Thread Derick Rethans
On Mon, 12 Jul 2004, Sebastian Bergmann wrote:

> Andi Gutmans wrote:
> > How about default($var, expr)?
>
>   It might be a good idea to decide on a name for the construct before
>   the PHP 5.0.0 release in order to make it a reserved word (marked for
>   future use).

Agreed, and I also like default()

Derick

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Sebastian Bergmann
Andi Gutmans wrote:
How about default($var, expr)?
 It might be a good idea to decide on a name for the construct before
 the PHP 5.0.0 release in order to make it a reserved word (marked for
 future use).
--
Sebastian Bergmann
http://sebastian-bergmann.de/   http://phpOpenTracker.de/
Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-php5.de/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Jason Garber

AG> How about default($var, expr)?

I like it.

-Jason

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Andi Gutmans
How about default($var, expr)?
Andi
At 09:43 AM 7/11/2004 -0700, Rasmus Lerdorf wrote:
On Sun, 11 Jul 2004, Marcus Boerger wrote:
>   $a = ifsetor($_GET['index'], $default);
ifsetor() sounds a bit cumbersome to me.
Some other suggestions:
$a = is($_GET['index'], $default);
$a = isor($_GET['index'], $default);
$a = valid($_GET['index'], $default);
$a = value($_GET['index'], $default);
-Rasmus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Curt Zirzow
* Thus wrote Rasmus Lerdorf:
> On Sun, 11 Jul 2004, Marcus Boerger wrote:
> 
> >   $a = ifsetor($_GET['index'], $default);
> 
> ifsetor() sounds a bit cumbersome to me.
> 
> ...
> 
> $a = value($_GET['index'], $default);

I like value() although it might be a bit too generic, maybe add
a word to it to help understand what the call does:

$a = valueof($_GET['index'], $default);

$a = valueor($_GET['index'], $default);



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Sterling Hughes
On Sun, 11 Jul 2004 09:43:51 -0700 (PDT), Rasmus Lerdorf <[EMAIL PROTECTED]> wrote:
> On Sun, 11 Jul 2004, Marcus Boerger wrote:
> 
> >   $a = ifsetor($_GET['index'], $default);
> 
> ifsetor() sounds a bit cumbersome to me.
> 
> Some other suggestions:
> 
> $a = is($_GET['index'], $default);
> 
> $a = isor($_GET['index'], $default);
> 
> $a = valid($_GET['index'], $default);

I don't like valid, because that implies checks that aren't there
(some sort of sanitizing).

> 
> $a = value($_GET['index'], $default);
> 

all of the other ones sound good - i like value() the best.

-sterling

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Rasmus Lerdorf
On Sun, 11 Jul 2004, Marcus Boerger wrote:

>   $a = ifsetor($_GET['index'], $default);

ifsetor() sounds a bit cumbersome to me.

Some other suggestions:

$a = is($_GET['index'], $default);

$a = isor($_GET['index'], $default);

$a = valid($_GET['index'], $default);

$a = value($_GET['index'], $default);

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New construct discussion Summary (was: what happened to that new isset() like language construct)

2004-07-11 Thread Marcus Boerger
Hello Marc,

Sunday, July 11, 2004, 4:49:57 AM, you wrote:

> Ok, so let me try to do a little summary.


> If and When
> ---
> 1) There seems to be a general consensus that this feature should be 
> implemented in SOME way.
> 2) It was too late for 5.0.0 so it will be targeted for 5.1


> What
> 
> The requirements seem be:
> a) return the first variable/expression that isset()
> b) no error shouldbe thrown for unset variables
> c) short circuit evaluation




> How
> ---
> 1) ?: has been rejected for the following reasons.
>   - Possible confusion with the ternary operator
>   - Asymmetry with the ternary operator - since it tests isset()
>   - It is non-obvious in its functionality in and of itself
>   - It would be difficult to find info on it in the Docs
>   - There is no WIDESPREAD use in other languages (though it is used in 
> GCC) and PHP has been very strict about not introducing new operators 
> that are not already widely used (only 2 in 10 years)


> 2) Jason Garber suggested the following syntax: $a = $b setor $c;

> While I like the fact that it is an operator instead of function, and
> therefore eases the process of chaining multiple operations together, I 
> see a problem.  Most PHP operators use non-alphanumeric characters, 
> therefore making it easier to quickly see the difference between 
> variable names and operators.  I believe the primary exceptions are 
> "or", "and", and "xor".  These were most likely added because of a 
> similarity with perl and can kinda get away with it since they are so 
> short. "setor" just doesn't look like an operator to me.


> 3) So this leaves a function call which begs two questions: What do we 
> call it, and what is the function syntax.

> (a) What do we call it

> Various suggestions have been rejected because of similarity to existing 
> keywords.  These include: ifset(), ifelse(), ifexists() and probably a 
> few more.

> We can't extend isset() perform this functionality because isset() 
> already takes multiple parameters.

> nvl(), ifnull() and coalesce() have been proposed because of similar 
> existing functions in Oracle, MySQL and Postgres.  However Marcus has 
> pointed out that these function test for null while we are testing for 
> existence.  I also think that since these functions are 1) not WIDELY 
> used and 2) not terribly intuitively named (with the possible exception 
> of coalesce) we should probably not use them unless we are unable to 
> come up with something else.

> This currently leaves us with a hand full of names, including: 
> ifsetor(), firstset(), getval()/getvalue()/get_value() (Is there a rule 
> about underscores in new function names?).


> (b) What is the function syntax?

> Marcus has already looked into the issue and already created a patch, 
> the existing patch only takes one variable and an optional default
> value (any expression).

> "ifsetor" "("  [ ","  ] ")"

> According to Marcus:

> "Changing it to accept a list of *variables* could probably be possible 
> but would require heavy restructuring of the compiler. The same is true 
> for chaining it to accept a variable plus a list of expressions is even 
> more complicated."

> Christian seem to be intent on trying to make it work, preferably with 
> the following format:

> "coalesce" "("  ( ","  )* ")"

> Andi thinks we should "make a decision what the best way to go is and 
> then we can discuss implementation if/what is possible".  They will both 
> probably not have time to look at this until after 5.0 is out.


> My current preference is

> "getval" "("  ( ","  )* ")"

Marc, excellent work.

While reading this again i only missed the obvious ability to nest
ifsetor() calls (your own idea btw) to emulate coalesce. Anyway it may
be the best idea to simply apply the patch for ifsetor and find a way
to implement coalesce with exactly that name. I also think this is the
way to go if enough people want coalesce because in the majority of time
the situation that led to ifsetor doesn't require nor even has a need
for coalesce. To me it seems the call for coalesce only occured because
some people knew it from SQL and thought it could be more powerfull.

BUT remember that situation. It is the need to write E_NOTICE free
code and hence dealing with probably unset array indices or other
uninitialized data most probably from some form input. There you
currently need to do:
  $a = isset($_GET['index']) ? $_GET['index'] : $default;
and this we want to change to:
  $a = ifsetor($_GET['index'], $default);
and there is no need for coalesce. Coalesce comes into play when it
gets more complicated like when you implement fall backs. And also
the fallbacks are uninitialized. And again a but. But typically the
fallbacks come from ini or whatever files or databases. For all these
origins of data the values are define. If no we come to Marc's idea
of nesting:
  $a = ifsetof($a, ifsetor($fallback, $default));
If it turns out that a majority