Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?id=50003
What do you think about enabling such a constructions in future versions of
php?
Br,
-melfar
Hi Melfar, from my point of view I am totally to make this a legal
call like in python or ruby java,
as I liked compact code I liked to avoid temp vars especially on a
read-only call, but it might require some effort there and the final
patch might be not so simple, anyway this is a community call, what I
can say about this kind of missing feature "sometimes, I can hear in
my office" : "PHP is a retarded language, PHP sucks or worst", my
point there, that is sometimes good to listen to people who are not
"passionate" by the language but just using it to do their job and be
paid.
Cheers!
Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?id=50003
What do you think about enabling such a constructions in future versions of
php?Br,
-melfar
Hey,
Yep, I think there might be some caveats to that change.
The original patch did not work on methods, so I've fixed that and also
made the return value an rvalue, so that you can't attempt to modify the
temporary value, the zend_check_writable_variable guard will yield an error.
The updated patch can be found at http://bugs.php.net/bug.php?id=50003
I've also heard an opinion that adding this construction is just going to
make things more
complicated, but take this: chained -> operators are supported for return
values and I'm only seeing code getting simpler because of that.
Br,
-melfar
"mm w" 0xcafefeed@gmail.com wrote:
Hi Melfar, from my point of view I am totally to make this a legal
call like in python or ruby java,
as I liked compact code I liked to avoid temp vars especially on a
read-only call, but it might require some effort there and the final
patch might be not so simple, anyway this is a community call, what I
can say about this kind of missing feature "sometimes, I can hear in
my office" : "PHP is a retarded language, PHP sucks or worst", my
point there, that is sometimes good to listen to people who are not
"passionate" by the language but just using it to do their job and be
paid.Cheers!
Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?id=50003
What do you think about enabling such a constructions in future versions
of
php?Br,
-melfar
2009/11/7 melfar melfar@gmail.com:
Hey,
Yep, I think there might be some caveats to that change.
The original patch did not work on methods, so I've fixed that and also
made the return value an rvalue, so that you can't attempt to modify the
temporary value, the zend_check_writable_variable guard will yield an error.The updated patch can be found at http://bugs.php.net/bug.php?id=50003
I've also heard an opinion that adding this construction is just going to
make things more
complicated, but take this: chained -> operators are supported for return
values and I'm only seeing code getting simpler because of that.Br,
-melfar"mm w" 0xcafefeed@gmail.com wrote:
Hi Melfar, from my point of view I am totally to make this a legal
call like in python or ruby java,
as I liked compact code I liked to avoid temp vars especially on a
read-only call, but it might require some effort there and the final
patch might be not so simple, anyway this is a community call, what I
can say about this kind of missing feature "sometimes, I can hear in
my office" : "PHP is a retarded language, PHP sucks or worst", my
point there, that is sometimes good to listen to people who are not
"passionate" by the language but just using it to do their job and be
paid.Cheers!
Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?id=50003
What do you think about enabling such a constructions in future versions
of
php?Br,
-melfar--
--
Whilst you are all thinking about this, how about ...
$value = (function(){return $x;})();
Being able to call an anonymous function inline would certainly be a
useful mechanism. Allowing calls without creating dummy user land vars
would be consistent with func()[0].
--
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
Whilst you are all thinking about this, how about ...
$value = (function(){return $x;})();
Being able to call an anonymous function inline would certainly be a
useful mechanism. Allowing calls without creating dummy user land vars
would be consistent with func()[0].
If you care not to waste userland with new names, use namespaces,
that's the way intruduced by php, and it is not javascript after all.
2009/11/8 jvlad dmda@yandex.ru:
Whilst you are all thinking about this, how about ...
$value = (function(){return $x;})();
Being able to call an anonymous function inline would certainly be a
useful mechanism. Allowing calls without creating dummy user land vars
would be consistent with func()[0].If you care not to waste userland with new names, use namespaces,
that's the way intruduced by php, and it is not javascript after all.--
I'm so old school in my coding, I've not got my head around namespaces
yet. I'm just old.
--
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
If you care not to waste userland with new names, use namespaces,
that's the way intruduced by php, and it is not javascript after all.I'm so old school in my coding, I've not got my head around namespaces
yet. I'm just old.
There is nothing really "new" in namespaces.
For example the concept of namespaces in c++ was introduced in the beginning
of 90s.
JavaScript with anonymous functions appeared later, in 95-96.
I'm not about whichever came first, just wanted to mention that neither as a
feature is new.
Hi!
Whilst you are all thinking about this, how about ...
$value = (function(){return $x;})();
I tried implementing that but it's not straightforward because you need
to keep the result of first call while everything inside () is
calculated (which can be any number of expressions including function
calls etc.) which wouldn't work with naive implementation, since by
default it doesn't have correct refcount to be preserved and if you
change it you need to add cleanup somewhere.
BTW I'm not sure the ()[] works there too - did you try to put some
complex expressions with multiple fcalls inside []?
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
""melfar"" melfar@gmail.com wrote in message
news:0F.F6.03668.AD206FA4@pb1.pair.com...
Hey,
Yep, I think there might be some caveats to that change.
The original patch did not work on methods, so I've fixed that and also
made the return value an rvalue, so that you can't attempt to modify the
temporary value, the zend_check_writable_variable guard will yield an
error.The updated patch can be found at http://bugs.php.net/bug.php?id=50003
I've also heard an opinion that adding this construction is just going to
make things more
complicated, but take this: chained -> operators are supported for return
values and I'm only seeing code getting simpler because of that.Br,
-melfar
- the patch introduces 5 more grammar conflicts. Did you check them all?
- can't call the results useful. Instead of returning possibly long array
and fetching just
one element, why not to add an argument to the funtion - the index of the
element
to be returned? - if you badly need the "function" returning an array and you prefer syntax
to performance,
think about indexed class property implemented via setters/getters:
class A {
public function __get($prop) {
if ($prop == "b")
return array('a' => 'b');
}
}
$a = new A();
echo $a->b['a'];
Class instance is where you'll keep the context.
If you don't need any context, static properties would be useful, but they
can't be
implemented via setters/getters and this is a thing should be changed in
order to get
the following sample working:
<?php
class A {
public static function __get($prop) {
if ($prop == "b")
return array('a' => 'b');
}
}
echo A::$b['a'];
?>
I think php is not that bad after all :)
just 2c.
It's already on the list for PHP6:
http://wiki.php.net/summits/pdmnotesmay09 (see Day 2, PHP 6, #13).
No need to discuss this further, I think. You might also want to have
that bug closed, it's redundant.
- David
Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?
id=50003
What do you think about enabling such a constructions in future
versions of
php?Br,
-melfar
Hello!
I have filed a bug (suggestion) at http://bugs.php.net/bug.php?id=50003
What do you think about enabling such a constructions in future
versions of
php?
It's already on the list for PHP6:
http://wiki.php.net/summits/pdmnotesmay09 (see Day 2, PHP 6, #13).
No need to discuss this further, I think. You might also want to
have that bug closed, it's redundant.
There's also a declined-ish RFC on this matter:
Regards,
Philip