On 26 September 2014 18:41:02 GMT+01:00, Lars Strojny wrote:
>That is exactly my point: instead of "optimising" the switch/case
>construct which is good enough as if/elseif/else replacement I feel our
>time would be better spent on thinking of polymorphism, guards and
>pattern matching.
That soun
Hi Rowan,
On 26 Sep 2014, at 18:11, Rowan Collins wrote:
[...]
> Without the additional guarantees provided by a purely functional
> environment, that's really just inverting the function header and if
> statement.
>
> Adding an extra case to that still means repeating the operator, so isn't t
Lars Strojny wrote (on 26/09/2014):
Hi everyone,
On 24 Sep 2014, at 23:17, Rowan Collins wrote:
switch ( $number ) use ( === ) {
[...]
switch ( $age ) use ( < ) {
[...]
switch ( calculate_age($birth_date, $departure_date) as $age_at_departure ) use (
< ) {
[...]
switch ( $product ) use
Hi everyone,
On 24 Sep 2014, at 23:17, Rowan Collins wrote:
> switch ( $number ) use ( === ) {
[...]
> switch ( $age ) use ( < ) {
[...]
> switch ( calculate_age($birth_date, $departure_date) as $age_at_departure )
> use ( < ) {
[...]
> switch ( $product ) use ( instanceOf ) {
All of these exa
Christian Stoller wrote (on 25/09/2014):
From: Rowan Collins [mailto:rowan.coll...@gmail.com], Sent: Thursday, September
25, 2014 12:31 PM
Sorry, I was talking about this bit:
Currently, switch always uses a "loose" comparison (==), so cannot
distinguish between "case 3" and "case 3.0". Occas
From: Rowan Collins [mailto:rowan.coll...@gmail.com], Sent: Thursday, September
25, 2014 12:31 PM
>
> Sorry, I was talking about this bit:
>
>> Currently, switch always uses a "loose" comparison (==), so cannot
>> distinguish between "case 3" and "case 3.0". Occasionally, it would be
>> nice t
Christian Stoller wrote (on 25/09/2014):
Am I missing something equally obvious there? Or just, it doesn't
>interest people much as an idea?
Why should one add a new operator in that context if it is already
possible with assigments as expressions?
This makes the language more complex without g
Mit freundlichen Grüßen aus Paderborn
Christian Stoller
Softwareentwicklung
LEONEX Internet GmbH
Technologiepark 20
33100 Paderborn
Tel: 05251-14807-27
Fax: 05251-14807-30
HRB 8694 AG Paderborn
Geschäftsführer: Stephan Winter
-
Rowan Collins wrote (on 24/09/2014):
On 24/09/2014 22:33, Andrea Faulds wrote:
On 24 Sep 2014, at 22:17, Rowan Collins wrote:
Perhaps rather than a magic function or constant, though, the switch
statement could be extended with an "as" argument, which would store
the evaluated expression int
On 24/09/2014 22:33, Andrea Faulds wrote:
On 24 Sep 2014, at 22:17, Rowan Collins wrote:
Perhaps rather than a magic function or constant, though, the switch statement could be
extended with an "as" argument, which would store the evaluated expression into
a normal variable, allowing nesting
On 24 Sep 2014, at 22:17, Rowan Collins wrote:
> Perhaps rather than a magic function or constant, though, the switch
> statement could be extended with an "as" argument, which would store the
> evaluated expression into a normal variable, allowing nesting, and easier
> optimisation of the en
You can already do:
$a = 1;
$b = 2;
switch( $switch_value = $a + $b ) {
default:
print $switch_value;
}
No magic or new operator required
-- S.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
On 23/09/2014 08:29, Sanford Whiteman wrote:
>> The `get_the_used_switch_variable()` is just a placeholder, name can be
>> changed to something natural...maybe a constant.
>
> I feel this has diminished utility once you consider that the "switch
> variable" is actually an expression and could well
Hi Martin,
> The `get_the_used_switch_variable()` is just a placeholder, name can be
> changed to something natural...maybe a constant.
I feel this has diminished utility once you consider that the "switch
variable" is actually an expression and could well include multiple
$variables. Plus there'
Hello together,
i often write switches, where i throw an Exception when something unknown
come in, rather than using a default value.
switch($myVar){
case 1:
doSomethingElse();
break;
case 2:
doSomething();
break;
//...
default:
throw new Exception('Undefined input
15 matches
Mail list logo