Re: [PHP] Function-return-array idea

2008-01-17 Thread Nathan Nobbe
On Jan 16, 2008 6:32 PM, Stijn Leenknegt [EMAIL PROTECTED] wrote:

 Hello

 I've an idea for PHP6. Let's kickoff with an example.

 ?php
 $info = getUserInformation($id); //return an array with all the
 information
 of an user.
 echo $info['naam'];
 ?

 This is nice, but when I want one element of the returned array, I have to
 store the returned array into a variable and then call the variable.
 The next code example is my idea.

 ?php
 echo getUserInformation($id)['naam'];
 ?

 Let's look further then this small example.

 ?php
 echo $object-fetchObjects()[0]-method();
 ?

 This example is more realistic when you use OO. This code style is faster
 for developing applications. This code style is available in Java,
 Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
 more on my blog


i think this is pretty much a dup of a thread from about a week ago;
http://www.nabble.com/Why-is-some_function()-some_index--invalid-syntax--td14749459.html

-nathan


Re: [PHP] Function-return-array idea

2008-01-17 Thread Eric Butera
On Jan 16, 2008 6:32 PM, Stijn Leenknegt [EMAIL PROTECTED] wrote:
 Hello

 I've an idea for PHP6. Let's kickoff with an example.

 ?php
 $info = getUserInformation($id); //return an array with all the information
 of an user.
 echo $info['naam'];
 ?

 This is nice, but when I want one element of the returned array, I have to
 store the returned array into a variable and then call the variable.
 The next code example is my idea.

 ?php
 echo getUserInformation($id)['naam'];
 ?

 Let's look further then this small example.

 ?php
 echo $object-fetchObjects()[0]-method();
 ?

 This example is more realistic when you use OO. This code style is faster
 for developing applications. This code style is available in Java,
 Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
 more on my blog.

 http://www.eos-team.org/2007/09/06/php6-function-return-array-idea.html

 I hope for good response and also response from php-dev team.

 Greetings
 Stijn Leenknegt


My reply is a bit pointless as I'd never do/rely on this.  But
nonetheless it was an interesting test.

function testObj() {
$arr = array();
$arr['key1'] = array(1, 2, 3);
$arr['key3'] = array('a','b','c');
return (object)$arr;
}

echo 'pre';

echo Key1: \n;
print_r(testObj()-key1);
echo Key3: \n;
print_r(testObj()-key3);


--- output 
Key1:
Array
(
[0] = 1
[1] = 2
[2] = 3
)
Key3:
Array
(
[0] = a
[1] = b
[2] = c
)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Function-return-array idea

2008-01-17 Thread Jim Lucas

Jim Lucas wrote:
I think this would be an easier/quicker fix for you then requesting that 
the PHP developers re-write a large portion of the way PHP currently works.




Here is the reference that I have been looking for.

http://en.wikipedia.org/wiki/Message_passing

Jim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Function-return-array idea

2008-01-16 Thread Stijn Leenknegt
Hello

I've an idea for PHP6. Let's kickoff with an example.

?php
$info = getUserInformation($id); //return an array with all the information
of an user.
echo $info['naam'];
?

This is nice, but when I want one element of the returned array, I have to
store the returned array into a variable and then call the variable.
The next code example is my idea.

?php
echo getUserInformation($id)['naam'];
?

Let's look further then this small example.

?php
echo $object-fetchObjects()[0]-method();
?

This example is more realistic when you use OO. This code style is faster
for developing applications. This code style is available in Java,
Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
more on my blog.

http://www.eos-team.org/2007/09/06/php6-function-return-array-idea.html

I hope for good response and also response from php-dev team.

Greetings
Stijn Leenknegt


Re: [PHP] Function-return-array idea

2008-01-16 Thread Richard Lynch
On Wed, January 16, 2008 5:32 pm, Stijn Leenknegt wrote:
 I've an idea for PHP6. Let's kickoff with an example.

This belongs on php-internals...

 ?php
 echo getUserInformation($id)['naam'];
 ?

where it has already been discussed at length, and, as I recall,
rejected as too obfuscated for the intent of PHP.

I apologize to php-internals for my gross over-simplification of a
zillion posts. :-)

Read the php-internals archives for the gory details.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Function-return-array idea

2008-01-16 Thread Jim Lucas
I think this would be an easier/quicker fix for you then requesting that 
the PHP developers re-write a large portion of the way PHP currently works.



?php

function i($arr, $i) {
return $arr[$i];
}

echo i(getUserInformation($id), 'naam');
#or
echo i($object-fetchObjects(), 0)-method();

?

Stijn Leenknegt wrote:

Hello

I've an idea for PHP6. Let's kickoff with an example.

?php
$info = getUserInformation($id); //return an array with all the information
of an user.
echo $info['naam'];
?

This is nice, but when I want one element of the returned array, I have to
store the returned array into a variable and then call the variable.
The next code example is my idea.

?php
echo getUserInformation($id)['naam'];
?

Let's look further then this small example.

?php
echo $object-fetchObjects()[0]-method();
?

This example is more realistic when you use OO. This code style is faster
for developing applications. This code style is available in Java,
Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
more on my blog.

http://www.eos-team.org/2007/09/06/php6-function-return-array-idea.html

I hope for good response and also response from php-dev team.

Greetings
Stijn Leenknegt




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Function-return-array idea

2008-01-16 Thread Per Jessen
Stijn Leenknegt wrote:

 This is nice, but when I want one element of the returned array, I
 have to store the returned array into a variable and then call the
 variable. The next code example is my idea.
 
 ?php
 echo getUserInformation($id)['naam'];
 ?
 
 Let's look further then this small example.
 
 ?php
 echo $object-fetchObjects()[0]-method();
 ?

Yeah, I like the idea.  I've often used that style out of habit, only to
have to revert to assigning the result to a variable etc. 
I don't know why it isn't supported by PHP, but I suspect it is related
to the type-concept. 


/Per Jessen, Zürich

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php