Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] what happened to that new isset() like language [RSS Feed]

#1 July 8, 2004 02:07:12

Marc R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Jason Garber wrote:Hi Marc,What we basically settled on was to use this syntax (as a new language
construct):$x = ifsetor(mixed variable, mixed default);So ?: is out then? Or just delayed until it can be tackled.If I recall correctly, Marcus had a patch that implemented it and it was
going to be plugged in in the 4.1 branch (when it is created).5.1?--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 July 8, 2004 02:20:39

Jason G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Hi Marc,At 7/7/2004 09:06 PM -0400, Marc Richards wrote:Jason Garber wrote:Hi Marc,What we basically settled on was to use this syntax (as a new language
construct):$x = ifsetor(mixed variable, mixed default);So ?: is out then? Or just delayed until it can be tackled.Who am I to say it's out for good? :)I just thought that the general consensus was a function like call, rather
than a new operator. I do remember that there was fairly strong support
for both, but there were various disadvantages to a new operator vs a new
"function" call.On a related note, does anyone know when 5.1 is going to be
branched? Shortly after the 5.0.0 release, I assume.If I recall correctly, Marcus had a patch that implemented it and it was
going to be plugged in in the 4.1 branch (when it is created).5.1?Yep.--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php-Jason--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 July 8, 2004 04:45:02

Andi G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


At 09:20 PM 7/7/2004 -0400, Jason Garber wrote:On a related note, does anyone know when 5.1 is going to be
branched? Shortly after the 5.0.0 release, I assume.Yeah I'd like to branch 5.0 off right away as there are some things I'd
like to start working on, mainly some performance patches.Andi--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#4 July 8, 2004 16:13:45

Christian S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Jason Garber wrote:What we basically settled on was to use this syntax (as a new language
construct):$x = ifsetor(mixed variable, mixed default);Before it gets forgotten: I still think that
$x = ifsetor(mixed var, mixed var );
with expressions in all parts is the way to go.Example usage:
$a = ifsetor($_REQUEST, $db->get('x'), 'default_x');This needs some work to disable warnings because of unset values inside
the ifsetor() but would provide a lot of value.And I also think that the name ifsetor has to be reevaluated :-)- Chris--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#5 July 8, 2004 16:19:59

Marc R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Christian Schneider wrote:Before it gets forgotten: I still think that
$x = ifsetor(mixed var, mixed var );
with expressions in all parts is the way to go.Example usage:
$a = ifsetor($_REQUEST, $db->get('x'), 'default_x');The other syntax could work for that as well...$a = $_REQUEST ?: $db->get('x') ?: 'default_x';and with a little white-space it is even more readable:$a = $_REQUEST ?: $db->get('x') ?: 'default_x';Marc--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#6 July 8, 2004 17:31:36

Rasmus L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


On Thu, 8 Jul 2004, Marc Richards wrote:
> Christian Schneider wrote:
>
> > Before it gets forgotten: I still think that
> > $x = ifsetor(mixed var, mixed var );
> > with expressions in all parts is the way to go.
> >
> > Example usage:
> > $a = ifsetor($_REQUEST, $db->get('x'), 'default_x');
> >
>
> The other syntax could work for that as well...
>
> $a = $_REQUEST ?: $db->get('x') ?: 'default_x';
>
>
> and with a little white-space it is even more readable:
>
> $a = $_REQUEST ?: $db->get('x') ?: 'default_x';

That syntax is way too confusing.

Spotting the difference between:

$a = $b ?: $c ?: $d;

$a = $b ? $c : $d;

is non-trivial and the two would do completely different things.

This needs to be a function that people can easily look up in the
documentation.

-Rasmus

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

Offline

#7 July 8, 2004 17:41:28

Derrell ..
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Christian Schneider <> writes:

> Before it gets forgotten: I still think that
> $x = ifsetor(mixed var, mixed var );
> with expressions in all parts is the way to go.
>
> Example usage:
> $a = ifsetor($_REQUEST, $db->get('x'), 'default_x');
>
> And I also think that the name ifsetor has to be reevaluated :-)

This is the exact usage and meaning of the SQL function coalesce(). That may
be an appropriate name.

>From the sqlite documentation:

coalesce(X,Y,...) Return a copy of the first non-NULL argument. If all
arguments are NULL then NULL is returned. There must be
at least 2 arguments.

And from the postgres documentation:

COALESCE(value )

The COALESCE function returns the first of its arguments that is not
null. Null is returned only if all arguments are null. This is often
useful to substitute a default value for null values when data is
retrieved for display, for example:

SELECT COALESCE(description, short_description, '(none)') ...

Like a CASE expression, COALESCE will not evaluate arguments that are not
needed to determine the result; that is, arguments to the right of the
first non-null argument are not evaluated.

The coalesce() function is from the ANSI/ISO SQL:1999 standard, so its use has
been around for a while.

Derrell

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

Offline

#8 July 8, 2004 19:53:41

Marcus B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Hello Christian,

Thursday, July 8, 2004, 5:13:36 PM, you wrote:

> Jason Garber wrote:
>> What we basically settled on was to use this syntax (as a new language
>> construct):
>> $x = ifsetor(mixed variable, mixed default);

> Before it gets forgotten: I still think that
> $x = ifsetor(mixed var, mixed var );
> with expressions in all parts is the way to go.

As i wrote before several times before to me this seems impossible. But
maybe someone can come up with a working patch?

Best regards,
Marcusmailto:

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

Offline

#9 July 8, 2004 21:43:08

Christian S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Marcus Boerger wrote:As i wrote before several times before to me this seems impossible. But
maybe someone can come up with a working patch?I'll have a look at it as soon as I find time (not this week anyway).What I'm looking for is the equivalent of
coalesce($a, $b) == @($a ? $a : b)
or
coalesce($a, $b, $c) == @($a ? $a : ($b ? $b : $c))
e.g. a silenced version of a multi-value ?: operator.Or to go back to my initial examplecoalesce($_REQUEST, $db->get('x'), 'default_x') ==@($_REQUEST ? $_REQUEST : ($_x = $db->get('x') ? $_x :
'default_x'))This is definitely not impossible and I consider the silencing of the
whole function call inside the coalesce() construct a non-problem. (If
someone wanted to do a version where stuff inside function calls aren't
silenced any more then one'd need to track the nesting level. I myself
wouldn't care.)- Chris--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#10 July 8, 2004 22:52:11

Marc R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] what happened to that new isset() like language


Rasmus Lerdorf wrote:On Thu, 8 Jul 2004, Marc Richards wrote:Christian Schneider wrote:Before it gets forgotten: I still think that
$x = ifsetor(mixed var, mixed var );
with expressions in all parts is the way to go.Example usage:
$a = ifsetor($_REQUEST, $db->get('x'), 'default_x');The other syntax could work for that as well...$a = $_REQUEST ?: $db->get('x') ?: 'default_x';and with a little white-space it is even more readable:$a = $_REQUEST ?: $db->get('x') ?: 'default_x';That syntax is way too confusing.Spotting the difference between:$a = $b ?: $c ?: $d;$a = $b ? $c : $d;is non-trivial and the two would do completely different things.That is true for other things as well:$a = $b += $c += $d;$a = $b + $c = $d;That doesn't make them inheritly evil. Adding white-space and brackets
can make it even more readable.$a = ($b ?: ($c ?: $d));$a = ($b ? $c : $d);This needs to be a function that people can easily look up in the
documentation.Does it? There are other similar constructs that don't e.g. +=, $a ? $b
: $c, .=;I think that part of the reason that these things are so terse is
because if would defeat the whole point to use a function name; The aim
is to be concise.If what marcus says about only being able to take two areguments is
true, then it makes an even stronger case, lest we end up with:$a = ifsetor($b, ifsetor($c, $d));Marc--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] what happened to that new isset() like language [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support